• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
B2G OS
  1. MDN
  2. Archive of obsolete content
  3. B2G OS
  4. B2G OS APIs
  5. BluetoothGatt (Firefox OS)

BluetoothGatt (Firefox OS)

In This Article
  1. Interface overview
  2. Properties
  3. Event handlers
  4. Methods
  5. Specifications
  6. Browser Compatibility
  7. See also

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

  • Desktop
  • Mobile
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

Tags: 
  • API
  • B2G
  • Bluetooth
  • BluetoothGatt
  • Certified
  • Firefox OS
  • Interface
  • Non-standard
  • Reference
  • Web Bluetooth
 Contributors to this page: chrisdavidmills
 Last updated by: chrisdavidmills, Feb 27, 2017, 2:38:41 AM
See also
  1. Web Bluetooth API
  2. Archive
  3. Related pages for Bluetooth API (Firefox OS)
    1. BluetoothAdapter
    2. BluetoothAdapterEvent
    3. BluetoothAttributeEvent
    4. BluetoothClassOfDevice
    5. BluetoothDevice
    6. BluetoothDeviceEvent
    7. BluetoothDiscoveryHandle
    8. BluetoothGatt
    9. BluetoothGattCharacteristic
    10. BluetoothGattCharacteristicEvent
    11. BluetoothGattDescriptor
    12. BluetoothGattServer
    13. BluetoothGattService
    14. BluetoothLeDeviceEvent
    15. BluetoothManager
    16. BluetoothPairingEvent
    17. BluetoothPairingHandle
    18. BluetoothPairingListener