Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Get the current state of the Bluetooth adapter.
my.getBluetoothAdapterState({ success(res) { console.log('Bluetooth available:', res.available); console.log('Discovering:', res.discovering); } });
Page({ async checkBluetoothState() { my.getBluetoothAdapterState({ success: (res) => { if (!res.available) { my.alert({ title: 'Bluetooth Unavailable', content: 'Please enable Bluetooth to continue.' }); return; } if (res.discovering) { console.log('Already scanning...'); } else { this.startDiscovery(); } } }); }, startDiscovery() { my.startBluetoothDevicesDiscovery({ success: () => console.log('Started scanning') }); } });
Page({ data: { bluetoothStatus: 'unknown' }, updateStatus() { my.getBluetoothAdapterState({ success: (res) => { let status = 'Off'; if (res.available) { status = res.discovering ? 'Scanning' : 'Ready'; } this.setData({ bluetoothStatus: status }); } }); } });