title: Taro.getBLEDeviceCharacteristics(option)

sidebar_label: getBLEDeviceCharacteristics

Gets all characteristics in a Bluetooth device service.

Reference

Type

  1. (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

  1. Taro.getBLEDeviceCharacteristics({
  2. // This deviceId must have been used to connect the appropriate device via createBLEConnection.
  3. deviceId,
  4. // This serviceId must be obtained in the getBLEDeviceServices API.
  5. serviceId,
  6. success: function (res) {
  7. console.log('device getBLEDeviceCharacteristics:', res.characteristics)
  8. }
  9. })

API Support

API WeChat Mini-Program H5 React Native
Taro.getBLEDeviceCharacteristics ✔️