title: Taro.getConnectedBluetoothDevices(option)
sidebar_label: getConnectedBluetoothDevices
Gets devices in the connected status based on the UUIDs.
Reference
Type
(option: Option) => void
Parameters
Option
| Property |
Type |
Required |
Description |
| services |
string[] |
Yes |
The list of primary service UUIDs of Bluetooth devices |
| 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 |
| devices |
BluetoothDeviceInfo[] |
The list of discovered devices |
| errMsg |
string |
success: ok; fail: error message. |
BluetoothDeviceInfo
| Property |
Type |
Description |
| deviceId |
string |
Device ID |
| name |
string |
The name of the Bluetooth device. Some devices may not have a name. |
Sample Code
Taro.getConnectedBluetoothDevices({ success: function (res) { console.log(res) }})
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| Taro.getConnectedBluetoothDevices |
✔️ |
|
|