title: Taro.getBLEDeviceServices(option)

sidebar_label: getBLEDeviceServices

Gets all services of a Bluetooth device.

Reference

Type

  1. (option: Option) => Promise<SuccessCallbackResult>

Parameters

Option

Property Type Required Description
deviceId string Yes The Bluetooth device ID
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
services BLEService[] The device service list
errMsg string success: ok,fail: error message

BLEService

res.services is composed as follows

Property Type Description
isPrimary boolean Indicates whether this service is the primary service
uuid string The Bluetooth device service UUID

Sample Code

  1. Taro.getBLEDeviceServices({
  2. // This deviceId must have been used to connect the appropriate device via createBLEConnection.
  3. deviceId,
  4. success: function (res) {
  5. console.log('device services:', res.services)
  6. }
  7. })

API Support

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