BluetoothGatt (Firefox OS)

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

The BluetoothGatt interface of the Web Bluetooth API handles initial communications and connections with Gatt services.

Interface overview

interface BluetoothGatt : EventTarget
  [Cached, Pure]
  readonly attribute sequence<<a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService">BluetoothGattService</a>> <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">services</a>;
  readonly attribute <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">BluetoothConnectionState</a> <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">connectionState</a>;

           attribute EventHandler <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">oncharacteristicchanged</a>;
           attribute EventHandler <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">onconnectionstatechanged</a>;

  [NewObject] Promise<void> <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">connect()</a>;
  [NewObject] Promise<void> <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">disconnect()</a>;
  [NewObject] Promise<void> <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">discoverServices()</a>;
  [NewObject] Promise<short> <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">readRemoteRssi()</a>;
  // Reliable write
  [NewObject] Promise<void> <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">beginReliableWrite()</a>;
  [NewObject] Promise<void> <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">executeReliableWrite()</a>;
  [NewObject] Promise<void> <a href="" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt">abortReliableWrite()</a>;

Properties Read only
Returns the list of GATT services offered by the remote LE device. This property is set to an empty array by default before a connection is established.
The current connection state of GATT client to the remote LE device. This property is set to disconnected by default, before a connection is established.

Event handlers

Defines a handler to trigger as a result of the characteristicchanged event firing; this occurs when a remote characteristic changes.
Defines a handler to trigger as a result of the connectionstatechanged event firing; this occurs when the connection state of the GATT client to the remote LE device (i.e. the BluetoothGatt.connectionState property) changes.


Connects to the remote LE device.
Disconnects an already-established connection to a remote LE device.
Discovers services, characteristics, and descriptors offered by the remote GATT server.
Reads the RSSI for a connected remote LE device.
Initiates a reliable write transaction for the remote LE device.
Executes all queued up characteristic value write operations for the remote LE device.
Cancels all queued characteristic value write operations for the remote LE device.


Specification Status Comment
Web Bluetooth
The definition of 'BluetoothGatt' in that specification.
Draft Rough draft; not part of any official specification yet. It should be discussed as part of the W3C's System Applications Working Group.

Browser Compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support No support No support No support No support No support
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support No support No support 2.1 No support No support No support No support


See also

Using the Web Bluetooth API


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API B2G Bluetooth BluetoothGatt Certified Firefox OS Interface Non-standard Reference Web Bluetooth