plus.bluetooth.onBLECharacteristicValueChange()
plus.bluetooth.onBLEConnectionStateChange()
plus.bluetooth.onBluetoothDeviceFound()
连接蓝牙流程中,每次连接都会重新触发一次以上函数,断开蓝牙服务的api也没有销毁这类监听,并且暂时没有找到官方解决方案。
项目中加入标识符判断是否曾经执行过以上监听事件,如果有则不再执行。
例:
let valueChangeEventListener = false;
if (!valueChangeEventListener) {
// 监听低功耗蓝牙设备的特征值变化
plus.bluetooth.onBLECharacteristicValueChange(function(e) {
... ...
});
valueChangeEventListener = true
}