title: Taro.getBLEDeviceServices(option)
sidebar_label: getBLEDeviceServices
Gets all services of a Bluetooth device.
Reference
Type
(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
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
| API |
WeChat Mini-Program |
H5 |
React Native |
| Taro.getBLEDeviceServices |
✔️ |
|
|