my.getBluetoothDevices
Use this API to get all the bluetooth devices that are discovered, including those that are connected to the current device.
Instructions:
- You may not get the advertisData and RSSI in the simulator. Please debug in the production environment.
- For Integrated Development Environment (IDE) and Android devices, the device ID is the MAC address of the device; for iOS devie, the device ID is the UUID of the device. Therefore, do not hard code the device ID. You need to process the device ID on different platforms; iOS devices can be dynamically matched based on properties such as localName, advertisData, and manufacturerData.
Note:
Currently simulation in IDE is not supported. Please debug in the production environment.
Code Sample
copy
my.getBluetoothDevices({
success: (res) => {
console.log(res)
},
fail:(res) => {
},
complete: (res)=>{
}
});
Parameters
The input parameters are displayed in the following table:
Property | Type | Required | Description |
success | Function | No | The callback function for a successful API call. |
fail | Function | No | The callback function for a failed API call. |
complete | Function | No | The callback function for a completed API call (Regardless of whether the call is successful or not). |
Success Callback Function
The input parameters are displayed in the following table:
Property | Type | Description |
devices | Array | A list of all the devices that are discovered. |
Device Object
Property | Type | Description |
name | String | Name of the bluetooth device.(For some devices, there's no name.) |
deviceName(Compatibal with initial version) | String | Name of the bluetooth device. |
localName | String | Name of the local device. |
deviceId | String | Device ID |
RSSI | Number | Received Signal Strength Indicator |
advertisData | Hex String | Advertisement data of the device |
manufacturerData | Hex String | Manufacturer data of the device |