my.writeBLECharacteristicValue

Use this API to write data to Bluetooth Low Energy (BLE) device characteristics.

Instructions:

  • The written binary data needs Hex coding.

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

Sample Code

copy
my.writeBLECharacteristicValue({
  deviceId: deviceId,
  serviceId: serviceId,
  characteristicId: characteristicId,
  value: 'fffe',
  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.
valueHex StringYesThe value corresponding to the Bluetooth device characteristic, which is a hexadecimal string, limited to 20 bytes.
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.