Parameters
Success Callback Parameters
Device Object Properties
Code Example
Basic Usage
Display Device List
Sort by Signal Strength
Related APIs
my.onBluetoothDeviceFound
Listen for new devices
my.getConnectedBluetoothDevices
Get connected devices
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Get all discovered Bluetooth devices.
| Property | Type | Required | Description |
|---|---|---|---|
| success | Function | No | Callback on success |
| fail | Function | No | Callback on failure |
| complete | Function | No | Callback that always executes |
| Property | Type | Description |
|---|---|---|
| devices | Array | List of discovered devices |
| Property | Type | Description |
|---|---|---|
| deviceId | String | Device ID |
| name | String | Name of the Bluetooth device (some devices may not have a name) |
| deviceName | String | Name of the Bluetooth device |
| localName | String | Name of the local device |
| RSSI | Number | Received Signal Strength Indicator |
| advertisData | Hex String | Advertisement data of the device |
| manufacturerData | Hex String | Manufacturer data of the device |
my.getBluetoothDevices({
success(res) {
console.log('Found devices:', res.devices);
}
});
Page({
data: {
devices: []
},
refreshDeviceList() {
my.getBluetoothDevices({
success: (res) => {
// Filter devices with names
const namedDevices = res.devices.filter(d => d.name);
this.setData({ devices: namedDevices });
}
});
}
});
Page({
getDevicesBySignal() {
my.getBluetoothDevices({
success: (res) => {
// Sort by RSSI (closer devices first)
const sorted = res.devices.sort((a, b) => b.RSSI - a.RSSI);
this.setData({ devices: sorted });
}
});
}
});
my.onBluetoothDeviceFound instead.