my.offBLECharacteristicValueChange
Use this API to unlisten to the BLE device characteristic change event.
Note:
Currently simulation in IDE is not supported. Please debug in production environment.
Sample Code
copy
Page({
onLoad() {
this.callback = this.callback.bind(this);
my.onBLECharacteristicValueChange(this.callback);
},
onUnload() {
my.offBLECharacteristicValueChange(this.callback);
},
callback(res) {
console.log(res);
},
})
Parameters
Property | Type | Description |
deviceId | String | The Bluetooth device ID. |
serviceId | String | The UUID of the service corresponding to a Bluetooth characteristic. |
characteristicId | String | The Bluetooth device characteristic UUID. |
value | Hex String | The latest hexadecimal value of the characteristic. |
Whether to pass callback value or not
- If the callback value is not passed, the callbacks of all events will be removed. The sample code is as follows:
copy
my.offBLECharacteristicValueChange();
- If the callback value is passed, only the corresponding callback is removed. The sample code is as follows:
copy
my.offBLECharacteristicValueChange(this.callback);