WebAPI/WebBluetooth: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:
===== Adapter =====
===== Adapter =====


interface nsIDOMBluetoothAdapter : nsIDOMEventTarget
  interface nsIDOMBluetoothAdapter : nsIDOMEventTarget
{
  {
  attribute boolean powered;
    attribute boolean powered;
  attribute boolean discoverable;
    attribute boolean discoverable;
  readonly attribute DOMString address;
    readonly attribute DOMString address;
readonly attribute unsigned long class;
    readonly attribute unsigned long class;
attribute DOMString name;
    attribute DOMString name;
attribute boolean pairable;
    attribute boolean pairable;
attribute unsigned long pairabletimeout;
    attribute unsigned long pairabletimeout;
attribute unsigned long discoverabletimeout;
    attribute unsigned long discoverabletimeout;
readonly attribute boolean discovering;
    readonly attribute boolean discovering;
 
   
void startDiscovery();
    void startDiscovery();
void stopDiscovery();
    void stopDiscovery();
     
    attribute nsIDOMEventListener ondevicefound;
    attribute nsIDOMEventListener onpropertychanged;
    attribute nsIDOMEventListener ondevicedisappeared;
    attribute nsIDOMEventListener ondevicecreated;
    attribute nsIDOMEventListener ondeviceremoved; 
  };
    
    
attribute nsIDOMEventListener ondevicefound;
  attribute nsIDOMEventListener onpropertychanged;
attribute nsIDOMEventListener ondevicedisappeared;
attribute nsIDOMEventListener ondevicecreated;
attribute nsIDOMEventListener ondeviceremoved; 
};


===== Device =====
===== Device =====

Revision as of 19:37, 7 February 2012

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 for audio and communication.

Future versions may include OBEX and profile support.

B2G Needs

Boot2Gecko 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, B2G will require its own settings and initialization code, so the focus of the API is on that platform for the time being.

Implementation Specifics

For communicating with the bluetooth adapter and devices on B2G, we will be using the DBus message system. This allows us to easily access all parts of the bluetooth system on B2G based platforms, without having to worry about GPL licensing issues.

DOM API

Adapter
 interface nsIDOMBluetoothAdapter : nsIDOMEventTarget
 {
   attribute boolean powered;
   attribute boolean discoverable;
   readonly attribute DOMString address;
   readonly attribute unsigned long class;
   attribute DOMString name;
   attribute boolean pairable;
   attribute unsigned long pairabletimeout;
   attribute unsigned long discoverabletimeout;
   readonly attribute boolean discovering;
   
   void startDiscovery();
   void stopDiscovery();
     
   attribute nsIDOMEventListener ondevicefound;
   attribute nsIDOMEventListener onpropertychanged;
   attribute nsIDOMEventListener ondevicedisappeared;
   attribute nsIDOMEventListener ondevicecreated;
   attribute nsIDOMEventListener ondeviceremoved;  
 };
 
Device

DBus Usage and Licensing

Bluetooth on Linux and B2G is accessed via the Bluez bluetooth stack. This stack is GPL, and the libraries that come with it to access bluetooth sockets are also GPL. To remove the licensing issues involved with this, the DBus communications layer is used to provide an IPC route for bluetooth related code. The WebBluetooth API (on Linux and B2G) will use DBus to keep the code compatible with the MPL.

DBus on Linux and Android

There are many ways to access DBus from code. On linux, gecko already uses the glib bindings for battery information on linux ([UPowerClient.cpp https://github.com/doublec/mozilla-central/blob/master/hal/linux/UPowerClient.cpp]). Android uses the low level DBus bindings, mainly made for writing language binding systems. This tends to create very complicated code, which even the DBus maintainers warn developers off of (See [DBus API Documentation http://dbus.freedesktop.org/doc/api/html/]).

On B2G, we'd like to avoid tying glib into the gecko build. We'll be using the [dbus-c++ http://gitorious.org/dbus-cplusplus] library on that platform in order to keep the dbus code simple and clean.

Links

Bugzilla

External

Relevant Source Code