BluetoothAdapter
#
DescriptionThe 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#
PropertiesBluetoothAdapter.discoverable
{.read-only}
A boolean indicating if the device is discoverable (true
) or not (false
) by other Bluetooth devices.
BluetoothAdapter.discovering
{.read-only}
A boolean indicating if the device's adapter is in the process of discovering (true
) or not (false
) surrounding Bluetooth devices.
BluetoothAdapter.name
{.read-only}
A string indicating the human readable name of the device's adapter.
BluetoothAdapter.state
{.read-only .no-link}
Returns the state of the local bluetooth adapter.
#
Event HandlersBluetoothAdapter.onattributechanged
A handler for theattributechanged
event; it is triggered when one of the local bluetooth adapter's properties has changedBluetoothAdapter.ondevicepaired
A handler for thedevicepaired
event; it is triggered when a remote device gets paired with the local bluetooth adapter.BluetoothAdapter.ondeviceunpaired
A handler for thedeviceunpaired
event; it is triggered when a remote device gets unpaired from the local bluetooth adapter.BluetoothAdapter.onpairingaborted
A handler for thepairingaborted
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 thea2dpstatuschanged
event; it is triggered when an A2DP connection status changes.BluetoothAdapter.onhfpstatuschanged
A handler for thehfpstatuschanged
event; it is triggered when an HFP connection status changes.BluetoothAdapter.onrequestmediaplaystatus
A handler for therequestmediaplaystatus
event; it is triggered when a remote Bluetooth device queries the current media play status.BluetoothAdapter.onscostatuschanged
A handler for thescostatuschanged
event; it is triggered when a SCO connection status changes.
Note: Because the
BluetoothAdapter
interface inherits from theEventTarget
interface, all these events can be listened by using theaddEventListener
method.
#
MethodsBluetoothAdapter.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 thediscoverable
property.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.