B2G/Bluetooth/WebBluetooth-v2/BluetoothManager

< B2G‎ | Bluetooth‎ | WebBluetooth-v2
Revision as of 07:53, 25 February 2014 by Btian (talk | contribs) (Created page with "== 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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

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