收藏
回答

蓝牙连接断开时收不到onBLEConnectionStateChanged回调

问题模块
API和组件

各位好,

测试使用的代码如下:

onShow: function () {

var that = this;


wx.onBLECharacteristicValueChange(function(res) {

var lang = that.data.recv_data;

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

console.log(String.fromCharCode.apply(null, new Uint8Array(res.value)))

lang += String.fromCharCode.apply(null, new Uint8Array(res.value))

that.setData({

recvTotalBytes : lang.length.toString(),

recv_data : lang,

scrollTop : that.data.scrollTop + 20

});

})


wx.onBLEConnectionStateChanged(function(res) {

console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`)

})

},


连接传输正常,但蓝牙异常断开(蓝牙设备直接断电)时收不到onBLEConnectionStateChanged回调,请问这是什么原因?

谢谢!

邀请回答
复制链接收藏投诉关注问题回答