BluetoothAdapter

This article is in need of a technical review.

« BluetoothAdapter

Non-standard
This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

This API is available on Firefox OS for certified applications only.

Summary

The BluetoothAdapter 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. Currently only one BluetoothAdapter object is supported on a device, which can be created from BluetoothManager.getDefaultAdapter(). In the whole Bluetooth API, it's the most important interface because it is used to manage all the interactions between local Bluetooth device and remote Bluetooth devices.

Interface overview

interface BluetoothAdapter: EventTarget
{
  readonly attribute DOMString address;
  readonly attribute unsigned long class;
  readonly attribute boolean discoverable;
  readonly attribute unsigned long discoverableTimeout;
  readonly attribute boolean discovering;
  readonly attribute BluetoothDevice[] devices;
  readonly attribute DOMString name;
  readonly attribute DOMString[] uuids;

  attribute EventHandler ona2dpstatuschanged;
  attribute EventHandler ondevicefound;
  attribute EventHandler onhfpstatuschanged;
  attribute EventHandler onpairedstatuschanged;
  attribute EventHandler onrequestmediaplaystatus;
  attribute EventHandler onscostatuschanged;

  DOMRequest answerWaitingCall();
  DOMRequest confirmReceivingFile(DOMString deviceAddress, boolean confirmation);
  DOMRequest connect(Bluetooth device, optional unsigned short serviceUuid);
  DOMRequest connectSco();
  DOMRequest disconnect(BluetoothDevice device, optional unsigned short serviceUuid);
  DOMRequest disconnectSco();
  DOMRequest getConnectedDevices();
  DOMRequest getPairedDevices();
  DOMrequest ignoreWaitingCall();
  DOMRequest isScoConnected();
  DOMRequest pair(BluetoothDevice device);
  DOMRequest sendFile(DOMString deviceAddress, Blob file);
  DOMRequest sendMediaMetaData(optional Object mediaMetaData);
  DOMRequest sendMediaPlayStatus(optional Object mediaPlayStatus);
  DOMRequest setDiscoverable(boolean discoverable);
  DOMRequest setDiscoverableTimeout(unsigned long timeout);
  DOMRequest setName(DOMString name);
  DOMRequest setPairingConfirmation(DOMString deviceAddress, boolean confirmation);
  DOMRequest setPasskey(DOMString deviceAddress, unsigned long passkey);
  DOMRequest setPinCode(DOMString deviceAddress, DOMString pinCode);
  DOMRequest startDiscovery();
  DOMRequest stopDiscovery();
  DOMRequest stopSendingFile(DOMString deviceAddress);
  DOMRequest toggleCalls();
  DOMRequest unpair(BluetoothDevice device);
};

Properties

BluetoothAdapter.address Read only
A string representing the address of the device's adapter.
BluetoothAdapter.class Read only
A number representing the Class of Device(CoD) field of the device's adapter.
BluetoothAdapter.discoverable Read only
A boolean indicating if the device is discoverable (true) or not (false) by other Bluetooth devices.
BluetoothAdapter.discoverableTimeout Read only
A number indicating how long (in seconds) the device remains discoverable.
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.devices Read only
An Array of BluetoothDevice object representing all the Bluetooth devices discovered in the area surrounding the device.
BluetoothAdapter.name Read only
A string indicating the human readable name of the device's adapter.
BluetoothAdapter.uuids Read only
An Array of string, each of them representing the UUID of a Bluetooth service the device's adapter is able to provide.

Event Handlers

BluetoothAdapter.ona2dpstatuschanged
A handler for the a2dpstatuschanged event; it is triggered when an A2DP connection status changes.
BluetoothAdapter.ondevicefound
A handler for the devicefound event; it is triggered when a Bluetooth device is found.
BluetoothAdapter.onhfpstatuschanged
A handler for the hfpstatuschanged event; it is triggered when an HFP connection status changes.
BluetoothAdapter.onpairedstatuschanged
A handler for the pairedstatuschanged event; it is triggered when a pairing process is completed.
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.

Methods

BluetoothAdapter.answerWaitingCall()
Allows HFP devices to answer a pending incoming call on a CDMA network.
BluetoothAdapter.confirmReceivingFile()
Allows to confirm reception of a file from a remote device.
BluetoothAdapter.connect()
Allows to connect the device to a remote device using a given Bluetooth profile.
BluetoothAdapter.connectSco()
Allows the device to enable the SCO connection to broadcast/listen audio to/from the remote devices it is connected to.
BluetoothAdapter.disconnect()
Allows to disconnect the device from a remote device for one or all Bluetooth profiles.
BluetoothAdapter.disconnectSco()
Allows the device to disable the SCO connection with the remote devices it is connected to.
BluetoothAdapter.getConnectedDevices()
Allows retrieving a full list of all devices connected to the device's adapter.
BluetoothAdapter.getPairedDevices()
Allows retrieving a full list of all devices paired with the device's adapter.
BluetoothAdapter.ignoreWaitingCall()
Allows HFP devices to dismiss a pending incoming call on a CDMA network.
BluetoothAdapter.isScoConnected()
Allows to know if the device is connected through a SCO connection with the remote devices it is connected to.
BluetoothAdapter.pair()
Allows to start pairing a remote device with the device's adapter.
BluetoothAdapter.sendFile()
Allows to start sending a file to a given remote device.
BluetoothAdapter.sendMediaMetaData()
Allows to send metadata about a media to remote devices connected with the AVRCP profile.
BluetoothAdapter.sendMediaPlayStatus()
Allows to send the play status of the device to remote devices connected with the AVRCP profile.
BluetoothAdapter.setDiscoverable()
Allows to change the value of the discoverable property.
BluetoothAdapter.setDiscoverableTimeout()
Allows to change the value of the discoverableTimeout property.
BluetoothAdapter.setName()
Allows to change the value of the name property.
BluetoothAdapter.setPairingConfirmation()
Allows to accept the pairing confirmation to pair the device's adapter with a remote device.
BluetoothAdapter.setPasskey()
Allows to define a pass key to pair the device's adapter with a remote device.
BluetoothAdapter.setPinCode()
Allows to define a pin code to pair the device's adapter with a remote device.
BluetoothAdapter.startDiscovery()
Allows the device's adapter to start seeking for remote devices.
BluetoothAdapter.stopDiscovery()
Allows the device's adapter to stop seeking for remote devices.
BluetoothAdapter.stopSendingFile()
Allows to stop sending a file to a given remote device.
BluetoothAdapter.toggleCalls()
Allows HFP devices to switch from one call to the other on a CDMA network.
BluetoothAdapter.unpair()
Allows to unpair a remote device from the device's adapter.

Specification

Not part of any specification yet. It should be discussed as part of the W3C's System Applications Working Group.

See also

Document Tags and Contributors

Contributors to this page: kscarfone, eric30, Sheppy, Jeremie
Last updated by: eric30,