title: Taro.getBLEDeviceCharacteristics(option)
sidebar_label: getBLEDeviceCharacteristics
Gets all characteristics in a Bluetooth device service.
Reference
Type
(option: Option) => Promise<SuccessCallbackResult>
Parameters
Option
Property |
Type |
Required |
Description |
deviceId |
string |
Yes |
The Bluetooth device ID |
serviceId |
string |
Yes |
The Bluetooth service UUID, which is obtained via getBLEDeviceServices |
complete |
(res: any) => void |
No |
The callback function used when the API call completed (always executed whether the call succeeds or fails) |
fail |
(res: any) => void |
No |
The callback function for a failed API call |
success |
(res: Result) => void |
No |
The callback function for a successful API call |
SuccessCallbackResult
Property |
Type |
Description |
characteristics |
BLECharacteristic[] |
The list of device characteristics |
errMsg |
string |
success: ok,fail: error message |
BLECharacteristic
res.characteristics is composed as follows
Property |
Type |
Description |
properties |
Properties |
The operation types supported by this characteristic |
uuid |
string |
The Bluetooth device characteristic UUID |
Properties
properties is composed as follows
Property |
Type |
Description |
indicate |
boolean |
Indicates whether this characteristic supports indicate operation |
notify |
boolean |
Indicates whether this characteristic supports notify operation |
read |
boolean |
Indicates whether this characteristic supports read operation |
write |
boolean |
Indicates whether this characteristic supports write operation |
Sample Code
Taro.getBLEDeviceCharacteristics({
// This deviceId must have been used to connect the appropriate device via createBLEConnection.
deviceId,
// This serviceId must be obtained in the getBLEDeviceServices API.
serviceId,
success: function (res) {
console.log('device getBLEDeviceCharacteristics:', res.characteristics)
}
})
API Support
API |
WeChat Mini-Program |
H5 |
React Native |
Taro.getBLEDeviceCharacteristics |
✔️ |
|
|