Version: Smart Feature Phone 2.5



The BluetoothAdapter interface of the Web Bluetooth API is used to handle all the operations requested by Bluetooth networks. A Bluetooth adapter is the physical interface which is used to interact with local Bluetooth device.

Interface overview#

interface BluetoothAdapter: EventTarget
readonly attribute BluetoothAdapterState state;
readonly attribute DOMString name;
readonly attribute boolean discoverable;
readonly attribute boolean discovering;
attribute EventHandler onattributechanged;
attribute EventHandler ondevicepaired;
attribute EventHandler ondeviceunpaired;
attribute EventHandler onpairingaborted;
attribute EventHandler ona2dpstatuschanged;
attribute EventHandler onhfpstatuschanged;
attribute EventHandler onscostatuschanged;
attribute EventHandler onrequestmediaplaystatus;
[NewObject] Promise<void> setDiscoverable(boolean aDiscoverable);
[NewObject] Promise<BluetoothDiscoveryHandle> startDiscovery();
[NewObject] Promise<void> stopDiscovery();
[NewObject] Promise<void> pair(DOMString aAddress);
[NewObject] Promise<void> unpair(DOMString aAddress);
sequence<BluetoothDevice> getPairedDevices();
// BLE methods
[NewObject] Promise<BluetoothDiscoveryHandle> startLeScan(sequence<DOMString> aServiceUuids);
[NewObject] Promise<void> stopLeScan(BluetoothDiscoveryHandle aDiscoveryHandle);


Event Handlers#

  • BluetoothAdapter.onattributechanged A handler for the attributechanged event; it is triggered when one of the local bluetooth adapter's properties has changed

  • BluetoothAdapter.ondevicepaired A handler for the devicepaired event; it is triggered when a remote device gets paired with the local bluetooth adapter.

  • BluetoothAdapter.ondeviceunpaired A handler for the deviceunpaired event; it is triggered when a remote device gets unpaired from the local bluetooth adapter.

  • BluetoothAdapter.onpairingaborted A handler for the pairingaborted event; it is triggered when pairing fails due to authentication failure, the remote device being down (bluetooth ACL becomes disconnected), or some kind of internal error.

  • BluetoothAdapter.ona2dpstatuschanged A handler for the a2dpstatuschanged event; it is triggered when an A2DP connection status changes.

  • BluetoothAdapter.onhfpstatuschanged A handler for the hfpstatuschanged event; it is triggered when an HFP connection status changes.

  • BluetoothAdapter.onrequestmediaplaystatus A handler for the requestmediaplaystatus event; it is triggered when a remote Bluetooth device queries the current media play status.

  • BluetoothAdapter.onscostatuschanged A handler for the scostatuschanged event; it is triggered when a SCO connection status changes.

Note: Because the BluetoothAdapter interface inherits from the EventTarget interface, all these events can be listened by using the addEventListener method.