api:wx.onBLECharacteristicValueChange
微信版本号:最新
基础库版本:最新
与一个产品在数据交互过程中只能获取一次设备的值,获取不到之后改变的值
/**
* 获取该服务所有特征值
*/
getCharacteristics(serviceId) {
const that = this
wx.getBLEDeviceCharacteristics({
deviceId: deviceId,
serviceId: serviceId,
success: function(res) {
for (let i = 0; i < res.characteristics.length; i++) {
if (res.characteristics[i].properties.write && writeFlag) {
//写操作
that.writeBLEValue(serviceId, res.characteristics[i].uuid)
writeFlag = false
}
if (res.characteristics[i].properties.notify && notifyFlag) {
//开启notify操作
that.notifyBLEValue(serviceId, res.characteristics[i].uuid)
notifyFlag = false
}
if (res.characteristics[i].properties.read && readFlag) {
//读操作
that.readBLEValue(serviceId, res.characteristics[i].uuid)
readFlag = false
}
}
},
})
this.onCharacteristic()
},