Skip to main content
Version: Next

Taro.getBLEDeviceServices(option)

Gets all services of a Bluetooth device.

Reference

Type

(option: Option) => Promise<SuccessCallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
deviceIdstringYesThe Bluetooth device ID
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

SuccessCallbackResult

PropertyTypeDescription
servicesBLEService[]The device service list
errMsgstringsuccess: ok,fail: error message

BLEService

res.services is composed as follows

PropertyTypeDescription
isPrimarybooleanIndicates whether this service is the primary service
uuidstringThe Bluetooth device service UUID

Sample Code

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

API Support

APIWeChat Mini-ProgramH5React Native
Taro.getBLEDeviceServices✔️