返回列表 发帖

wx.onBLECharacteristicValueChange(CALLBACK)

监听低功耗蓝牙设备的特征值变化。必须先启用notify接口才能接收到设备推送的notification。

CALLBACK参数说明:

参数        类型        说明
deviceId        string        蓝牙设备 id,参考 device 对象
serviceId        string        特征值所属服务 uuid
characteristicId        string        特征值 uuid
value        ArrayBuffer        特征值最新的值(注意:vConsole 无法打印出 ArrayBuffer 类型数据)
示例代码:

wx.onBLECharacteristicValueChange(function(res) {
  console.log(`characteristic ${res.characteristicId} has changed, now is ${res.value}`)
})

返回列表