蓝牙连接断开时收不到onBLEConnectionStateChanged回调
发布于 6 年前 作者 yangtao 11206 次浏览 来自 问答

各位好,

测试使用的代码如下:

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回调,请问这是什么原因?

谢谢!

回到顶部