// 开启实时发送开关
wx.writeBLECharacteristicValue({
deviceId: deviceId,
serviceId: serviceId,
characteristicId: characteristicId,
value: value,
success: function (res) {
// success
console.log(‘开启实时发送开关成功’);
console.log(res);
// 监听特征值变化
console.log(‘开始监听特征值变化’);
wx.onBLECharacteristicValueChange(function (res) {
console.log(`characteristic ${res.characteristicId} has changed, now is ${res.value}`);
console.log(res.value);
})
},
fail: function (res) {
// fail
console.log(‘开启实时发送开关失败’);
console.log(res);
},
complete: function (res) {
// complete
}
})
红色部分的代码在ios端可以进行执行,但是安卓端不执行