Board logo

标题: wx.notifyBLECharacteristicValueChanged(OBJECT) [打印本页]

作者: vicky.yu    时间: 7 小时前     标题: wx.notifyBLECharacteristicValueChanged(OBJECT)

启用低功耗蓝牙设备特征值变化时的 notify 功能。注意:必须设备的特征值支持notify才可以成功调用,具体参照 characteristic 的 properties 属性

另外,必须先启用notify才能监听到设备 characteristicValueChange 事件

OBJECT参数说明:

参数        类型        必填        说明
deviceId        string        是        蓝牙设备 id,参考 device 对象
serviceId        string        是        蓝牙特征值对应服务的 uuid
characteristicId        string        是        蓝牙特征值的 uuid
state        boolean        是        true: 启用 notify; false: 停用 notify
success        Function        是        成功则返回本机蓝牙适配器状态
fail        Function        否        接口调用失败的回调函数
complete        Function        否        接口调用结束的回调函数(调用成功、失败都会执行)
success返回参数:

参数        类型        说明
errMsg        string        成功:ok,错误:详细信息
示例代码:

wx.notifyBLECharacteristicValueChanged({
  state: true, // 启用 notify 功能
  // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
  deviceId: deviceId,
  // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
  serviceId: serviceId,
  // 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取
  characteristicId: characteristicId,
  success: function (res) {
    console.log('notifyBLECharacteristicValueChanged success', res.errMsg)
  }
})




欢迎光临 赛捷软件论坛 (http://www.sagesoft.cn/bbs/) Powered by Discuz! 7.2