基础库 1.1.0 开始支持,低版本需做兼容处理
读取低功耗蓝牙设备的特征值的二进制数据值。注意:必须设备的特征值支持read
才可以成功调用,具体参照 characteristic 的 properties 属性
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
deviceId | String | 是 | 蓝牙设备 id,参考 device 对象 |
serviceId | String | 是 | 蓝牙特征值对应服务的 uuid |
characteristicId | String | 是 | 蓝牙特征值的 uuid |
success | Function | 是 | 成功则返回本机蓝牙适配器状态 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success返回参数:
参数 | 类型 | 说明 |
---|---|---|
errCode | Number | 错误码 |
errMsg | String | 成功:ok,错误:详细信息 |
示例代码:
// 必须在这里的回调才能获取
wx.onBLECharacteristicValueChange(function(characteristic) {
console.log('characteristic value comed:', characteristic)
})
wx.readBLECharacteristicValue({
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接 [**new**]
deviceId: deviceId,
// 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
serviceId: serviceId,
// 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取
characteristicId: characteristicId,
success: function (res) {
console.log('readBLECharacteristicValue:', res.errCode)
}
})
全国7x24小时客服热线
所有故障均24小时内解决
项目一次性收费安心
技术人员均从业5年以上
通过技术营销传播企业服务价值
丰富的行业实战经验积累
基于需求研发多款产品
针对需求提供精细化服务