my.readBLECharacteristicValue

Use this API to read the data of Bluetooth Low Energy (BLE) device characteristics. The returned information must be obtained by using the callback in the my.onBLECharacteristicValueChange.

Instructions:

  • Multiple parallel reading and writing calls might cause failures.
  • If the reading times out, the error code is 10015. However, my.onBLECharacteristicValueChange interface might return data later. Please consider how to handle this situation.

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

Sample Code

copy
my.readBLECharacteristicValue({
  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.
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.

Success Callback Function

PropertyTypeDescription
characteristicObjectInformation of the device characteristic.

characteristic

Information of the Bluetooth device characteristic

PropertyTypeDescription
characteristicIdStringThe Bluetooth characteristic UUID.
serviceIdStringThe UUID of the service corresponding to a Bluetooth characteristic.
valueHex StringThe Bluetooth characteristic value.