Documentation Index
Fetch the complete documentation index at: https://docs.rebellapp.com/llms.txt
Use this file to discover all available pages before exploring further.
Use this API to stop discovering Bluetooth devices. Call this when you’ve found the device you need to save battery.
Parameters
| Property | Type | Required | Description |
|---|
| success | Function | No | Callback on success |
| fail | Function | No | Callback on failure |
| complete | Function | No | Callback that always executes |
Code Example
Basic Usage
my.stopBluetoothDevicesDiscovery({
success() {
console.log('Stopped scanning');
}
});
Stop When Device Found
Page({
targetDeviceName: 'MyDevice',
startScan() {
my.onBluetoothDeviceFound((res) => {
const targetDevice = res.devices.find(
d => d.name === this.targetDeviceName
);
if (targetDevice) {
// Found target, stop scanning
my.stopBluetoothDevicesDiscovery();
this.connectToDevice(targetDevice);
}
});
my.startBluetoothDevicesDiscovery();
},
connectToDevice(device) {
console.log('Connecting to:', device.name);
// Connect logic here
}
});
Scan with Timeout
Page({
scanTimeout: null,
startTimedScan() {
my.startBluetoothDevicesDiscovery({
success: () => {
// Auto-stop after 15 seconds
this.scanTimeout = setTimeout(() => {
my.stopBluetoothDevicesDiscovery();
my.showToast({ content: 'Scan complete' });
}, 15000);
}
});
},
stopScanEarly() {
if (this.scanTimeout) {
clearTimeout(this.scanTimeout);
}
my.stopBluetoothDevicesDiscovery();
}
});
my.startBluetoothDevicesDiscovery
Start discovery
my.getBluetoothDevices
Get discovered devices