HomeDocs
Skip to main content

dlt.readBLECharacteristicValue

Introduction​

Read the value of a characteristic.

Parameters​

Object object​

PropertyTypeDefaultRequiredDescription
serviceUUIDstringYesThe UUID of the service to which the characteristic belongs.
characteristicUUIDstringYesThe UUID of the characteristic to read.
successfunctionNoThe callback function for a successful API call.
failfunctionNoThe callback function for a failed API call.
completefunctionNoThe callback function that is called when the API call ends (whether it succeeds or fails).

object.success Callback Function​

Parameters​

Object res​

PropertyTypeDescription
successstringtrue - Success
serviceUUIDstringThe UUID of the service.
characteristicUUIDstringThe UUID of the characteristic.
valuestringThe value of the characteristic.
statusstringStatus

object.fail Callback Function​

Parameters​

Object res​

PropertyTypeDescription
successstringfalse - Failure
errCodestringError code

Explanation of Error Codes​

Error CodeDescription
-1Failed
0Normal
10000Bluetooth adapter uninitialized
10001Bluetooth not available
10002Device not found
10003Connection failed
10004Already connected
10005Characteristic not found
10006Descriptor not found
10007Location access required
10008System reports an exception
10013Invalid data
10014Permission not granted
10015Adapter already initialized

Sample Code​

dlt.readBLECharacteristicValue({
serviceUUID: 'xxx',
characteristicUUID: 'xxx',
success: function (res) {
console.log(res);
},
});

In the sample code provided, dlt.readBLECharacteristicValue is used to read the value of a specified characteristic. When the operation is successful, the success callback function is called, and it logs the result to the console.

Privacy agreementDeveloper agreementcontact us: developer_private.mi@dlightek.com © 2024 MiniApp. All Rights Reserved.