B2G/Bluetooth/WebBluetooth-v2/BluetoothManager
< B2G | Bluetooth | WebBluetooth-v2
Overview
The BluetoothManager API allows to access all Bluetooth adapters available on the device. Adapters are the connection interface to connect a Bluetooth device to that device.
Interface
interface BluetoothManager: EventTarget { attribute EventHandler onadapteradded; attribute EventHandler onadapterremoved; BluetoothAdapter[] getAdapters(); BluetoothAdapter getDefaultAdapter(); };
Event Handlers
- BluetoothManager.onadapteradded
- BluetoothManager.onadapterremoved
onadapteradded
- Summary
- A handler for the adapteradded event; it is triggered when a Bluetooth adapter is enabled on the device.
- Sample Code
navigator.mozBluetooth.onadapteradded = funcRef
- Where funcRef is a function to be called when the adapteradded event occurs.
onadapterremoved
- Summary
- A handler for the adapterremoved event; it is triggered when a Bluetooth adapter is disabled on the device.
- Sample Code
navigator.mozBluetooth.onadapterremoved = funcRef
- Where funcRef is a function to be called when the adapterremoved event occurs.
Methods
- BluetoothManager.getAdapters()
- BluetoothManager.getDefaultAdapter()
getAdapters()
- Summary
- The getAdapters method is used to retrieve all adapters of this device.
- Return
- The array of all BluetoothAdapter objects.
- Sample Code
var adapters = navigator.mozBluetooth.getAdapters();
getDefaultAdapter()
- Summary
- The getDefaultAdapter method is used to retrieve the default adapter used to connect the device to third-party Bluetooth devices.
- Return
- The default BluetoothAdapter object.
- Sample Code
- var adapter = navigator.mozBluetooth.getDefaultAdapter();
See also
- BluetoothAdapter