Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

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

[CheckPermissions="bluetooth"]
interface BluetoothGatt : EventTarget
{
  [Cached, Pure]
  readonly attribute sequence<BluetoothGattService> services;
  readonly attribute BluetoothConnectionState connectionState;

           attribute EventHandler oncharacteristicchanged;
           attribute EventHandler onconnectionstatechanged;

  [NewObject] Promise<void> connect();
  [NewObject] Promise<void> disconnect();
  [NewObject] Promise<void> discoverServices();
  [NewObject] Promise<short> readRemoteRssi();
  // Reliable write
  [NewObject] Promise<void> beginReliableWrite();
  [NewObject] Promise<void> executeReliableWrite();
  [NewObject] Promise<void> abortReliableWrite();
};

Properties

BluetoothGatt.services 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.
BluetoothGatt.connectionState
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

BluetoothGatt.oncharacteristicchanged
Defines a handler to trigger as a result of the characteristicchanged event firing; this occurs when a remote characteristic changes.
BluetoothGatt.onconnectionstatechanged
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.

Methods

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

Specifications

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

Document Tags and Contributors

 Contributors to this page: chrisdavidmills
 Last updated by: chrisdavidmills,