BluetoothAdapter
Description#
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#
Properties#
BluetoothAdapter.discoverableread-onlyA boolean indicating if the device is discoverable (true) or not (false) by other Bluetooth devices.BluetoothAdapter.discoveringread-onlyA boolean indicating if the device's adapter is in the process of discovering (true) or not (false) surrounding Bluetooth devices.BluetoothAdapter.nameread-onlyA string indicating the human readable name of the device's adapter.BluetoothAdapter.stateread-onlyno-linkReturns the state of the local bluetooth adapter.
Event Handlers#
BluetoothAdapter.onattributechangedA handler for theattributechangedevent; it is triggered when one of the local bluetooth adapter's properties has changedBluetoothAdapter.ondevicepairedA handler for thedevicepairedevent; it is triggered when a remote device gets paired with the local bluetooth adapter.BluetoothAdapter.ondeviceunpairedA handler for thedeviceunpairedevent; it is triggered when a remote device gets unpaired from the local bluetooth adapter.BluetoothAdapter.onpairingabortedA handler for thepairingabortedevent; 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.ona2dpstatuschangedA handler for thea2dpstatuschangedevent; it is triggered when an A2DP connection status changes.BluetoothAdapter.onhfpstatuschangedA handler for thehfpstatuschangedevent; it is triggered when an HFP connection status changes.BluetoothAdapter.onrequestmediaplaystatusA handler for therequestmediaplaystatusevent; it is triggered when a remote Bluetooth device queries the current media play status.BluetoothAdapter.onscostatuschangedA handler for thescostatuschangedevent; it is triggered when a SCO connection status changes.
Note: Because the
BluetoothAdapterinterface inherits from theEventTargetinterface, all these events can be listened by using theaddEventListenermethod.
Methods#
BluetoothAdapter.getPairedDevices()Allows retrieving a full list of all devices paired with the device's adapter.BluetoothAdapter.pair()Allows to start pairing a remote device with the device's adapter.BluetoothAdapter.setDiscoverable()Allows to change the value of thediscoverableproperty.BluetoothAdapter.startDiscovery()Allows the device's adapter to start seeking for remote devices.BluetoothAdapter.startLeScan()Instructs the device's adapter to start seeking for remote LE devices advertising given services.BluetoothAdapter.stopDiscovery()Allows the device's adapter to stop seeking for remote devices.BluetoothAdapter.stopLeScan()Instructs the device's adapter to stop scanning for remote LE devices.BluetoothAdapter.unpair()Allows to unpair a remote device from the device's adapter.