my.notifyBLECharacteristicValueChange

Use this API enable notification on change of Bluetooth Low Energy (BLE) device characteristics.
Instructions:

  • Subscription is more efficient and is recommended over the read method.

Note:
Currently simulation in IDE is not supported. Please debug in production environment.

Sample Code

copy
my.notifyBLECharacteristicValueChange({
  deviceId: deviceId,
  serviceId: serviceId,
  characteristicId: characteristicId,
  success: (res) => {
    console.log(res)
  },
  fail:(res) => {
  },
  complete: (res)=>{
  }
});

Parameters

PropertyType

Required

Description
deviceIdStringYesThe Bluetooth device ID.
serviceIdStringYesThe UUID of the service corresponding to a Bluetooth characteristic.
characteristicIdStringYesThe Bluetooth characteristic UUID.
descriptorIdStringNoDescriptor UUID of the notification. This is Android-specific, the default value is 00002902-0000-10008000-00805F9b34fb.
stateBooleanNoWhether notify or indicate is enabled.
successFunctionNoThe callback function for a successful API call.
failFunctionNoThe callback function for a failed API call.
completeFunctionNoThe callback function used when the API call is completed. This function is always executed no matter the call succeeds or fails.