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

PropertyTypeDescription
deviceIdStringThe Bluetooth device ID.
serviceIdString The UUID of the service corresponding to a Bluetooth characteristic.
characteristicIdStringThe Bluetooth device characteristic UUID.
valueHex StringThe 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);