MDN wants to talk to developers like you: https://qsurvey.mozilla.com/s3/8d22564490d8

BluetoothGattServer (Firefox OS)

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

The BluetoothGattServer interface of the Web Bluetooth API provides Bluetooth GATT server functionality to allow creation of Bluetooth Smart/LE services and characteristics.

Interface overview

[CheckPermissions="bluetooth"]
interface BluetoothGattServer
{
  [Cached, Pure] readonly attribute sequence<BluetoothGattService> services;

  attribute EventHandler ondeviceconnectionstatechanged;
  attribute EventHandler onattributereadreq;
  attribute EventHandler onattributewritereq;
          
  [NewObject] Promise<void> connect(DOMString address);
  [NewObject] Promise<void> disconnect(DOMString address);
  [NewObject] Promise<void> addService(BluetoothGattService service);
  [NewObject] Promise<void> removeService(BluetoothGattService service);
  [NewObject] Promise<void> notifyCharacteristicChanged(DOMString address, DOMString uuid, int instanceId, bool confirm);
  [NewObject] Promise<void> sendResponse(DOMString address, int status, int requestId, ArrayBuffer value);
};

Properties

BluetoothGattServer.services Read only
Returns an array of the services offered by this device.

Event handlers

BluetoothGattServer.ondeviceconnectionstatechanged
Defines a handler to trigger as a result of the deviceconnectionstatechanged event firing; this occurs when a remote LE device has been connected or disconnected.
BluetoothGattServer.onattributereadreq
Defines a handler to trigger as a result of the attributereadreq event firing; this occurs when a remote client has requested to read a server's characteristic or descriptor.
BluetoothGattServer.onattributewritereq
Defines a handler to trigger as a result of the attributewritereq event firing; this occurs when a remote client has requested to write a server's characteristic or descriptor.

Methods

BluetoothGattServer.connect()
Initiates a connection to a remote LE device.
BluetoothGattServer.disconnect()
Disconnects an already-established connection to a remote LE device.
BluetoothGattServer.addservice()
Adds a BluetoothGattService to the server's list of provided services.
BluetoothGattServer.removeservice()
Removes a BluetoothGattService from the server's list of provided services.
BluetoothGattServer.notifyCharacteristicChanged()
Sends a notification/indication that a local characteristic has been updated.
BluetoothGattServer.sendResponse()
Sends a response to a remote LE device's read or write request.

Specifications

Specification Status Comment
Web Bluetooth
The definition of 'BluetoothGattServer' 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,