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
JavaScript
Copy Code
[CheckPermissions="bluetooth"] interface BluetoothGattServer { [Cached, Pure] readonly attribute sequence<<a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#BluetoothGattService" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService">BluetoothGattService</a>> <a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer#services" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer">services</a>; attribute EventHandler <a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer#ondeviceconnectionstatechanged" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer">ondeviceconnectionstatechanged</a>; attribute EventHandler <a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer#onattributereadreq" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer">onattributereadreq</a>; attribute EventHandler <a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer#onattributewritereq" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer">onattributewritereq</a>; [NewObject] Promise<void> <a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer#connect.28DOMString_address" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer">connect(DOMString address)</a>; [NewObject] Promise<void> <a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer#disconnect.28DOMString_address.29" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer">disconnect(DOMString address)</a>; [NewObject] Promise<void> <a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer#addService.28BluetoothGattService_service.29" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer">addService(BluetoothGattService service)</a>; [NewObject] Promise<void> <a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer#removeService.28BluetoothGattService_service.29" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer">removeService(BluetoothGattService service)</a>; [NewObject] Promise<void> <a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer#notifyCharacteristicChanged.28DOMString_address.2C_DOMString_uuid.2C_int_instanceId.2C_bool_confirm.29" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer">notifyCharacteristicChanged(DOMString address, DOMString uuid, int instanceId, bool confirm)</a>; [NewObject] Promise<void> <a href="https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer#sendResponse.28DOMString_address.2C_int_status.2C_int_requestId.2C_ArrayBuffer_value.29" class="external" title="B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer">sendResponse(DOMString address, int status, int requestId, ArrayBuffer value)</a>; };
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
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/bluetoothgattserver