WebBluetooth

Goals

The aim of WebBluetooth is to establish a DOM API to set up and communicate with Bluetooth devices. This includes setting properties on adapters and devices, scanning for devices, bonding, and socket initialization.

Firefox OS Needs

Firefox OS is the main consumer of WebBluetooth for the moment. Most operating systems already provide a configuration layer for bluetooth, and we do not plan on overriding that. However, Firefox OS will require its own settings and initialization code, so the focus of the API is on that platform for the time being.

W3C Bluetooth Community Group is discussing on specification for Bluetooth APIs to allow websites to communicate with devices in a secure and privacy-preserving way. Google has proposed an intial API and use cases. Mozilla also participates in discussion to integrate Firefox OS Bluetooth APIs into the finalized version. See section Google Bluetooth APIs for more information about Google Bluetooth APIs.

BluetoothAdapter.webidl

// MediaMetadata and MediaPlayStatus are used to keep data from Applications.
// Please see specification of AVRCP 1.3 for more details.
dictionary MediaMetaData
{
// track title
DOMString title = "";
// artist name
DOMString artist = "";
// album name
DOMString album = "";
// track number
long long mediaNumber = -1;
// number of tracks in the album
long long totalMediaCount = -1;
// playing time (ms)
long long duration = -1;
};

dictionary MediaPlayStatus
{
// current track length (ms)
long long duration = -1;
// playing time (ms)
long long position = -1;
// one of 'STOPPED'/'PLAYING'/'PAUSED'/'FWD_SEEK'/'REV_SEEK'/'ERROR'
DOMString playStatus = "";
};

/*
* Set of attributes that might be changed and reported by attributechanged
* event.
* Address is not included since it should not be changed once BluetoothDevice
* is created.
*/
enum BluetoothDeviceAttribute
{
"unknown",
"cod",
"name",
"paired",
"uuids"
};

DOM API (Until Firefox OS 2.1)

Check pre-2.2 DOM API if you are interested in WebBluetooth API until Firefox OS v2.1.