xxxxxxxxxx
本SDK主要提供欧姆龙血压计、血糖仪、体脂仪、血氧仪的绑定、同步数据功能。
开发者从插件市场下载插件导入项目中,通过调用插件sdk提供的接口方法,实现对血压、血糖、体脂和血氧设备的操控。
No. | 术语 | 意义 | 欧姆龙开放平台中的位置 | 使用位置 |
---|---|---|---|---|
1 | appKey | 应用的密钥(开发者key)。 | 总览->应用->app-key | 参考[6.3 注册激活]章节 |
2 | packageSecret | 应用秘钥,在输入了android的应用包名后显示。 | 远程设备开放->开始集成->android->应用秘钥 | 参考[6.3 注册激活]章节 |
3 | packageName | 应用包名(App包名) | 远程设备开放->开始集成->android->应用包名 | 参考[6.3 注册激活]章节 |
4 | strLicense | 设备独立授权下载的离线License文件 | 远程设备开放->独立设备授权->License离线下载 | |
5 | thirdUserId | 第三方应用的用户识别码,可通过thirdUserId 锁定禁止用户使用sdk。thirdUserId长度不超过64位(非必填项)。 |
xxxxxxxxxx
OMRON_SDK_UnOpenBlueTooth(1, "蓝牙未开启,请开启蓝牙"),
OMRON_BLE_ERROR_NOT_SUPPORT(2, "该设备不支持蓝牙"),
OMRON_SDK_NoDevice(3, "扫描超时"),
OMRON_SDK_InValidKey(4, "厂商ID 无效"),
OMRON_SDK_ConnectFail(5, "连接失败"),
OMRON_SDK_UnBind(6, "请先绑定正确的设备"),
OMRON_SDK_UnRegister(7, "未注册"),
OMRON_SDK_NoNet(8, "请在网络连接状态下进行操作"),
OMRON_SDK_BindFail(9, "绑定失败"),
OMRON_SDK_TRANSFERFAIL(10, "未找到设备同步失败"),
OMRON_SDK_ADDRESS_EMPTY(11, "设备地址不存在"),
OMRON_SDK_INVALID_DEVICE_ADDRESS(12,"无效的设备地址"),
OMRON_BLE_ERROR_DEVICE_CAN_NOT_CONNECT(13,"无法与目标设备建立连接"),
OMRON_BLE_ERROR_DEVICE_NOT_CONNECT(14,"设备未连接"),
OMRON_BLE_ERROR_DEVICE_NOT_SUPPORT(15,"设备不支持该功能"),
OMRON_BLE_ERROR_DEVICE_DISCOVER_SERVICE(16,"无法获取设备服务"),
OMRON_BLE_ERROR_DEVICE_READ_ChARACTERISTIC(16,"无法读取信息"),
OMRON_BLE_ERROR_DEVICE_WRITE_DESCRIPTOR(17,"无法更改描述"),
OMRON_BLE_ERROR_DEVICE_BOND_FAILED(18,"配对失败"),
OMRON_BLE_ERROR_PERMISSION_BLE(19, "需要打开附近的设备权限"),
OMRON_BLE_ERROR_SYNC_EMPTY(20, "已同步至最新数据"),
OMRON_BLE_ERROR_DEVICE_CATEGORY_NOT_SUPPORT(21, "不支持该设备类别"),
OMRON_BLE_ERROR_DEVICE_TYPE_NOT_SUPPORT(22, "不支持该设备型号");
OMRON_BLE_ERROR_DEVICE_BOND_STATE_ERROR(23, "绑定状态错误,请在蓝牙列表中取消配对后再试"),
OMRON_BLE_ERROR_DEVICE_TYPE_EXPIRATION(24, "设备已过期,请延长使用期后继续使用"),
OMRON_BLE_ERROR_DEVICE_FAILED_TO_OVER_FINGERPRINT(25, "指纹授权量超过"),
OMRON_BLE_ERROR_DEVICE_THIRD_USER_BLOCKED(26, "当前用户已冻结")
OMRON_BLE_ERROR_FILE_EMPTY(27, "请允许网络数据访问或者配置离线license文件")
xxxxxxxxxx
// 血压数据
public class BPData {
//血压高压
private int systolic;
//低压
private int diastolic;
//脉搏
private int pulse;
//心率不齐状态
private int arrhythmiaFlg; // 0: normal; 1 abnormal
//身体移动状态
private int bmFlg; // 0:not move; 1 move
//臂带宽松状态
private int cwsFlg; // 0: normal; 1 abnormal
//测量使用者
private int measureUser; // 0:unset; 1:userA; 2:userB
//测量时间
private long measureTime;
//AF血压计三次测量
private int afibMode;
//房颤检测
private int afibFlg;// 0: normal; 1 abnormal
}
xxxxxxxxxx
public class BodyfatData {
/**
* 测量时间
* */
private String mMeasureTime;
/**
* 体重
* */
private String mWeight;
/**
* 体脂肪率
* */
private String mPercentage;
/**
* 骨骼肌率
* */
private String mSkeletal;
/**
* 基础代谢
* */
private String mBasal;
/**
* BMI
* */
private String mBmi;
/**
* 体年龄
* */
private String mAge;
/**
* 内脏脂肪
* */
private String mVisceral;
}
xxxxxxxxxx
public class BGData {
/** Record sequence number */
private int sequenceNumber;
/** The base time of the measurement */
private Calendar time;
/** The glucose concentration. 0 if not present */
private float glucoseConcentration;
/** mg/L mmol/L */
private Unit unit;
/**
* One of the following:<br/>
* 0 未设定<br/>
* 1 餐前<br/>
* 2 餐后<br/>
* 3 空腹<br/>
*/
private Meal meal;
}
xxxxxxxxxx
public class BOData {
//血氧饱和度
private String mOxygen;
//脉搏
private String mPulse;
}
xxxxxxxxxx
public class DeviceInfo {
// 设备类型
private String modelName;
// 设备序列号
private String serialNumber;
// 硬件版本号
private String hardwareVersion;
// 软件版本号
private String softwareVersion;
// 固件版本号
private String firmwareVersion;
// 设备电量
private Integer batteryLevel;
// 供电方式
private String powerSupplyMode;
// 制造商名称
private String manufacturerName;
// 设备代号
private String modelNumber;
// 设备系统ID
private String systemID;
}
xxxxxxxxxx
class DeviceCategory {
// 血压计
public static readonly BLOOD_PRESSURE: Int = 1;
// 血糖仪
public static readonly BLOOD_GLUCOSE: Int = 2;
// 体脂仪
public static readonly BODY_FAT: Int = 4;
// 血氧仪
public static readonly BLOOD_OXYGEN: Int = 5;
// 全部
public static readonly ALL_SUPPORT: Int = 0;
}
xxxxxxxxxx
import { init } from "@/uni_modules/omron-blesdk";
xxxxxxxxxx
export function init(options: CallBackInfoOptions) {
...
}
激活认证方法:
xxxxxxxxxx
@param appKey 开发者key
@param packageSecret 应用秘钥
@param packageName 应用包名
@param strLicense 应用离线License文件内容,当选择在线激活方式时,可设置为空
@param thirdUserId 第三方客户应用下用户识别码,如果不使用用户限制功能,可设置为空
@param options 回调函数
export function requestIdentifier(appKey: String, packageSecret: String, packageName: String, strLicense: String, thirdUserId: String, options: CallBackInfoOptions) {
OMRONManager.getInstance().requestIdentifierSDK(appKey, packageSecret, packageName, strLicense, thirdUserId, options);
}
xxxxxxxxxx
@param type 设备类型 1、血压计 2、血糖计 4、体脂仪
@param options 回调函数
export function getDeviceTypeList(deviceCategory: Int, options: CallBackInfoOptions) {
...
}
扫描的回调函数说明
xxxxxxxxxx
const callback = new class implements BleScanDeviceCallback {
override onBleScan(device : BleScanDevice, rssi : Int, scanRecord : ByteArray | null) : void {
console.log("Scanned device:", device);
...
}
override onCycleEnd() : void {
console.log("Scan cycle ended");
...
}
override onBleScanFailure(errMsg: OMRONBLEErrMsg) : void {
console.error("Scan failed:", errMsg);
...
}
}
扫描指定类别的绑定状态的设备
xxxxxxxxxx
@param deviceCategory 要扫描的绑定状态的设备类别
@param scanPeriod 扫描周期,最小1s,最大300s
@param options 回调函数
@UTSJS.keepAlive
export async function startBindScan(deviceCategory: Int, scanPeriod: Int, options: CallBackInfoOptions){
...
}
扫描已绑定的同步状态中的设备
xxxxxxxxxx
@param deviceList 要扫描的同步状态的设备
@param scanPeriod 扫描周期,最小1s,最大300s
@param options 回调函数
@UTSJS.keepAlive
export async function startSyncScan(deviceList: String , scanPeriod: Int, options: CallBackInfoOptions) {
...
}
所有扫描通用停止方法
xxxxxxxxxx
export function stopScan(options: CallBackInfoOptions) {
...
}
血压回调接口说明
xxxxxxxxxx
const createOmronBpCallback = (actionType: String, options: CallBackInfoOptions): OmronBpBleCallBack => {
class CommonOmronBpBleCallBack implements OmronBpBleCallBack {
private options: CallBackInfoOptions;
constructor(options: CallBackInfoOptions) {
this.options = options;
}
override onBindComplete(
deviceType: string,
deviceName: string | null,
deviceAddress: string,
deviceInfo: DeviceInfo,
bpDataList: List<BPData>
) {
console.log(`[SDK] 血压计${actionType} onBindComplete`);
const res = {
code: 200,
msg: `[SDK] 血压计${actionType}成功`,
data: {
deviceType,
deviceName,
deviceAddress,
deviceInfo,
bpDataList
}
};
this.options.success?.(res);
}
override onFailure(errMsg: OMRONBLEErrMsg) {
console.log(`[SDK] 血压计${actionType} onFailure`, errMsg);
const res = {
code: errMsg.getErrCode(),
msg: `[SDK] 血压计: ` + errMsg.getErrMsg()
};
this.options.fail?.(res);
}
override onDataReadComplete(
deviceType: string,
deviceName: string | null,
deviceAddress: string,
bpDataList: List<BPData>
) {
console.log(`[SDK] 血压计${actionType} onDataReadComplete`);
const res = {
code: 200,
msg: `[SDK] 血压计${actionType}完成`,
data: {
deviceType,
deviceName,
deviceAddress,
bpDataList
}
};
this.options.complete?.(res);
}
}
return new CommonOmronBpBleCallBack(options);
}
onFailure(errMsg: OMRONBLEErrMsg)
xxxxxxxxxx
OMRONBLEErrMsg为异常情况返回
onBindComplete(deviceType: string, deviceName: string | null, deviceAddress: string, deviceInfo: DeviceInfo, bpDataList: List
xxxxxxxxxx
**绑定接口成功返回**
deviceType 设备类型
deviceName 设备名称
deviceAddress 设备mac地址
deviceInfo 血压设备信息
bpDataList 血压测量数据
onDataReadComplete(deviceType: string, deviceName: string | null, deviceAddress: string, bpDataList: List
xxxxxxxxxx
**同步、监听数据成功返回**
deviceType 设备类型
deviceName 设备名称
deviceAddress 设备mac地址
bpDataList 血压测量数据
xxxxxxxxxx
@param deviceType 设备类型
@param options 回调函数
@param deviceAddress 设备mac地址 可为空
export async function bindBpDevice(deviceType: String, options: CallBackInfoOptions, deviceAddress: String) {
...
}
xxxxxxxxxx
export function stopBpConnect(options: CallBackInfoOptions) {
...
}
同步血压计测量数据:同步到血压计所有未同步过的血压数据。
xxxxxxxxxx
@param deviceType 设备类型
@param deviceName 设备名称
@param deviceAddress 设备mac地址
@param options 回调函数
export async function getBpDeviceData(deviceType:String, deviceName: String, deviceAddress: String, options: CallBackInfoOptions) {
...
}
调用该接口前须确保蓝牙开启;该接口不可与其他设备监听和数据同步接口同时使用。同步血压计所有未同步过的血压数据。
可以同时监听多个设备,推荐。
xxxxxxxxxx
@param deviceList 要监听的血压设备 (对象数组需先转成json字符串)
@param options 回调函数
@UTSJS.keepAlive
export async function startBpMonitoring(deviceList: String, options: CallBackInfoOptions) {
...
}
根据当前数据同步结果判断是否需要开启下次监听:
OMRON_SDK_NoDevice
、OMRON_SDK_ConnectFail
、OMRON_SDK_TRANSFERFAIL
、OMRON_BLE_ERROR_SYNC_EMPTY
和数据同步成功后继续监听,其他异常情况下停止监听
所有血压设备监听通用停止方法,退出监听时必须调用
xxxxxxxxxx
export function stopBpMonitoring(options: CallBackInfoOptions) {
...
}
体脂回调函数说明
xxxxxxxxxx
const createOmronBfCallback = (actionType: String, options: CallBackInfoOptions): OmronBfBleCallBack => {
class CommonOmronBfBleCallBack implements OmronBfBleCallBack {
private options: CallBackInfoOptions;
constructor(options: CallBackInfoOptions) {
this.options = options;
}
override onBindBodyFatComplete(
deviceType: string,
deviceName: string | null,
userindex: string,
deviceAddress: string,
sex: string,
height: string,
birthday: string,
deviceInfo: DeviceInfo,
bfDataList: List<BodyfatData>
) {
console.log(`[SDK] 体脂仪${actionType} onBindBodyFatComplete`);
...
}
override onFailure(errMsg: OMRONBLEErrMsg) {
console.log(`[SDK] 体脂仪${actionType} onFailure`, errMsg);
...
}
override onBodyFatDataReadComplete(
deviceType: string,
deviceName: string | null,
deviceAddress: string,
userindex: string,
bfDataList: List<BodyfatData>,
sex: string,
height: string,
birthday: string
) {
console.log(`[SDK] 体脂仪${actionType} onBodyFatDataReadComplete`);
...
}
override onScanBodyFatComplete(){
console.log(`[SDK] 体脂仪${actionType}选号位 onScanBodyFatComplete`);
...
}
}
return new CommonOmronBfBleCallBack(options);
}
onFailure(errMsg: OMRONBLEErrMsg)
xxxxxxxxxx
OMRONBLEErrMsg为异常情况返回
onBindBodyFatComplete(deviceType: string, deviceName: string | null, userindex: string, deviceAddress: string, sex: string, height: string, birthday: string, deviceInfo: DeviceInfo, bfDataList: List
xxxxxxxxxx
**绑定接口成功返回**
deviceType 设备类型
deviceName 设备名称
userindex 设备机位
deviceAddress 设备mac地址
sex 性别(Male,Female)
height 身高
birthday 生日
deviceInfo 体脂设备信息
bfDataList 体脂测量数据
onBodyFatDataReadComplete(deviceType: string, deviceName: string | null, deviceAddress: string, userindex: string, bfDataList: List
xxxxxxxxxx
**同步、监听数据成功返回**
deviceType 设备类型
deviceName 设备名称
userindex 设备机位
deviceAddress 设备mac地址
sex 性别(Male,Female)
height 身高
birthday 生日
bfDataList 体脂测量数据
onScanBodyFatComplete()
xxxxxxxxxx
**绑定过程中标记需要选择号位的返回接口**
xxxxxxxxxx
@param deviceType 设备类型
@param options 回调函数
@param birthday 生日
@param sex 性别
@param height 身高
export async function bindBfDevice(deviceType:String, options: CallBackInfoOptions,
birthday: String, sex: String, height: String) {
...
}
xxxxxxxxxx
@param userIndex 设备机位 1、2、3、4
@param options 回调函数
export async function bindBfUserIndex( userIndex: Int, options: CallBackInfoOptions ) {
...
}
xxxxxxxxxx
@param mDeviceType 设备类型
@param deviceAddress 设备mac地址
@param options 回调函数
@param userIndex 设备机位
@param birthday 生日
@param sex 性别
@param height 身高
@param deviceId 设备ID
export async function getBfDeviceData(deviceType:String, deviceAddress: String, options: CallBackInfoOptions,
userIndex: Int, birthday: String, sex: String, height: String, deviceId: String) {
...
}
xxxxxxxxxx
export function stopBfConnect(options: CallBackInfoOptions) {
...
}
调用该接口前须确保蓝牙开启;该接口不可与其他设备监听和数据同步接口同时使用;
根据当前数据同步结果判断是否需要开启下次监听:
OMRON_SDK_NoDevice
、OMRON_SDK_ConnectFail
、OMRON_SDK_TRANSFERFAIL
、OMRON_BLE_ERROR_SYNC_EMPTY
和数据同步成功后继续监听,其他异常情况下停止监听
可以同时监听多个设备,推荐。
xxxxxxxxxx
@param deviceList 要监听的体脂设备 (对象数组需先转成json字符串)
@param options 回调函数
@param birthday 用户生日
@param sex 用户性别
@param height 用户身高
@UTSJS.keepAlive
export async function startBfMonitoring(deviceList: String, options: CallBackInfoOptions, birthday: String, sex: String, height: String) {
...
}
所有体脂设备监听通用停止方法,退出监听时必须调用
xxxxxxxxxx
@param options 回调函数
export function stopBfMonitoring(options: CallBackInfoOptions) {
...
}
血糖回调函数说明
xxxxxxxxxx
const createOmronBgCallback = (actionType: String, options: CallBackInfoOptions): OmronBgBleCallBack => {
class CommonOmronBgBleCallBack implements OmronBgBleCallBack {
private options: CallBackInfoOptions;
constructor(options: CallBackInfoOptions) {
this.options = options;
}
override onBindComplete(
deviceType: string,
deviceName: string | null,
deviceAddress: string,
dataList: List<BGData>
) {
console.log(`[SDK] 血糖仪${actionType} onBindComplete`);
...
}
override onFailure(errMsg: OMRONBLEErrMsg) {
console.log(`[SDK] 血糖仪${actionType} onFailure`, errMsg);
...
}
override onDataReadComplete(
deviceType: string,
deviceName: string | null,
deviceAddress: string,
dataList: List<BGData>
) {
console.log(`[SDK] 血糖仪${actionType} onDataReadComplete`);
...
}
}
return new CommonOmronBgBleCallBack(options);
}
onFailure(errMsg: OMRONBLEErrMsg)
xxxxxxxxxx
OMRONBLEErrMsg为异常情况返回
void onBindComplete(deviceType: string, deviceName: string | null, deviceAddress: string, dataList: List
xxxxxxxxxx
**绑定接口成功返回**
deviceType 设备类型
deviceName 设备名称
deviceAddress 设备mac地址
dataList 血糖测量数据
void onDataReadComplete(deviceType: string, deviceName: string | null, deviceAddress: string, dataList: List
xxxxxxxxxx
**同步、监听数据成功返回**
deviceType 设备类型
deviceName 设备名称
deviceAddress 设备mac地址
dataList 血糖测量数据
xxxxxxxxxx
@param deviceType 设备类型
@param device 设备 (对象需先转成json字符串)
@param options 回调函数
export async function bindBgDevice(deviceType: String, device:String, options: CallBackInfoOptions) {
...
}
xxxxxxxxxx
@param deviceType 设备类型
@param device 设备 (对象需先转成json字符串)
@param options 回调函数
export async function getBgDeviceData(deviceType: String, device: String, options: CallBackInfoOptions) {
...
}
xxxxxxxxxx
export function stopBgConnect(options: CallBackInfoOptions) {
...
}
调用该接口前须确保蓝牙开启;该接口不可与其他设备监听和数据同步接口同时使用;
根据当前数据同步结果判断是否需要开启下次监听:
OMRON_SDK_NoDevice
、OMRON_SDK_ConnectFail
、OMRON_SDK_TRANSFERFAIL
、OMRON_BLE_ERROR_SYNC_EMPTY
和数据同步成功后继续监听,其他异常情况下停止监听
可以同时监听多个设备。
xxxxxxxxxx
@param deviceList 要监听的血糖设备 (对象数组需先转成json字符串)
@param options 回调函数
@UTSJS.keepAlive
export async function startBgMonitoring(deviceList: String, options: CallBackInfoOptions) {
...
}
所有血糖设备监听通用停止方法,退出监听时必须调用
xxxxxxxxxx
export function stopBgMonitoring(options: CallBackInfoOptions) {
...
}
血氧回调函数说明
xxxxxxxxxx
const createOmronBoCallback = (actionType: String, options: CallBackInfoOptions): OmronBoBleCallBack => {
class CommonOmronBoBleCallBack implements OmronBoBleCallBack {
private options: CallBackInfoOptions;
constructor(options: CallBackInfoOptions) {
this.options = options;
}
override onBoComplete(
deviceType: string,
deviceName: string | null,
deviceAddress: string,
deviceInfo: DeviceInfo,
boDataList: List<BoData>
) {
console.log(`[SDK] 血氧仪${actionType} onBoComplete`);
...
}
override onFailure(errMsg: OMRONBLEErrMsg) {
console.log(`[SDK] 血氧仪${actionType} onFailure`, errMsg);
...
}
override onBoDataReadComplete(
deviceType: string,
deviceName: string | null,
deviceAddress: string,
boDataList: List<BoData>
) {
console.log(`[SDK] 血氧仪${actionType} onBoDataReadComplete`);
...
}
}
return new CommonOmronBoBleCallBack(options);
}
onFailure(errMsg: OMRONBLEErrMsg)
xxxxxxxxxx
OMRONBLEErrMsg为异常情况返回
void onBoComplete(deviceType: string, deviceName: string | null, deviceAddress: string, deviceInfo: DeviceInfo, boDataList: List
xxxxxxxxxx
**绑定接口成功返回**
deviceType 设备类型
deviceName 设备名称
deviceAddress 设备mac地址
deviceInfo 血氧设备信息
boDataList 血氧测量数据
void onBoDataReadComplete(deviceType: string, deviceName: string | null, deviceAddress: string, boDataList: List
xxxxxxxxxx
**同步、监听数据成功返回**
deviceType 设备类型
deviceName 设备名称
deviceAddress 设备mac地址
boDataList 血氧测量数据
xxxxxxxxxx
@param deviceType 设备类型
@param options 回调函数
export async function bindBoDevice(deviceType:String, options: CallBackInfoOptions) {
...
}
xxxxxxxxxx
@param deviceType 设备类型
@param deviceName 设备名称
@param deviceAddress 设备mac地址
@param callBack 回调函数
export async function getBoDeviceData(deviceType:String, deviceName: String, deviceAddress: String, options: CallBackInfoOptions) {
...
}
xxxxxxxxxx
export function stopBoConnect(options: CallBackInfoOptions) {
...
}
调用该接口前须确保蓝牙开启;该接口不可与其他设备监听和数据同步接口同时使用;
根据当前数据同步结果判断是否需要开启下次监听:
OMRON_SDK_NoDevice
、OMRON_SDK_ConnectFail
、OMRON_SDK_TRANSFERFAIL
、OMRON_BLE_ERROR_SYNC_EMPTY
和数据同步成功后继续监听,其他异常情况下停止监听
可以同时监听多个设备。
xxxxxxxxxx
@param deviceList 要监听的血氧设备 (对象数组需先转成json字符串)
@param options 回调函数
@UTSJS.keepAlive
export async function startBoMonitoring(deviceList: String, options: CallBackInfoOptions) {
...
}
退出监听时必须调用
xxxxxxxxxx
export function stopBoMonitoring(options: CallBackInfoOptions){
...
}
蓝牙连接状态说明
xxxxxxxxxx
/**
* OmronStateEnum 说明
*
OMRONLIB_SCAN, //开始扫描
OMRONLIB_CONNECT, //开始链接
OMRONLIB_SYNC_DATA, //开始数据同步
OMRONLIB_SYNC_DATA_SUCCESS, //数据同步成功
OMRONLIB_SYNC_DATA_ERROR, //数据同步失败
OMRONLIB_DISCONNECTED; //断开链接
*
*/
xxxxxxxxxx
@UTSJS.keepAlive
export function setStatusBlock(options: CallBackInfoOptions){
OMRONManager.getInstance().setStatusBlockSDK(options);
}
xxxxxxxxxx
export function remStatusBlock(options: CallBackInfoOptions){
OMRONManager.getInstance().remStatusBlockSDK(options);
}
用户敏感信息可见等级说明
xxxxxxxxxx
'OMRONLOG_NONE'//不可见
'OMRONLOG_ALL'//可见
'OMRONLOG_HALF;//部分可见
xxxxxxxxxx
export function setLogType(level: String) {
...
}
日志等级说明
xxxxxxxxxx
/** 日志等级
*
'WARN'
'ERROR'
'FATAL'
*/
xxxxxxxxxx
export function setLimitation(level: String) {
...
}
xxxxxxxxxx
export function getDeviceFinger(options: CallBackInfoOptions) {
...
}