// 监听特征值变化
console.log(‘开始监听特征值变化’);
wx.onBLECharacteristicValueChange(function (res) {
// console.log(`characteristic ${res.characteristicId} has changed, now is ${res.value}`);
console.log("==============onBLECharacteristicValueChange================");
console.log(res);
});
setInterval(function () {
wx.readBLECharacteristicValue({
deviceId: deviceId,
serviceId: serviceId,
characteristicId: characteristicId,
success: function (res) {
// console.log(‘readBLECharacteristicValue:’, res.characteristic.value)
console.log("==============readBLECharacteristicValue================");
console.log(res);
// console.log(‘成功’);
},
fail: function (res) {
// console.log(“失败”);
},
complete: function (res) {
// console.log(“完成”);
}
})
}, 2000);
红色代码部分报错,经蓝色代码部分调试后发现不存在开发文档中的characteristic对象