B2G/Bluetooth/WebBluetooth-v2/BluetoothGattServer: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 39: Line 39:
; Default Value
; Default Value
: Empty array (array with length = 0)
: Empty array (array with length = 0)
== Event Handlers ==
=== ondeviceconnectionstatechanged ===
=== onattributereadreq ===
; Description
: A handler to trigger when connection state of certain GATT client has changed.
=== onattributewritereq ===
=== onexecutewritereq ===
== Methods ==
=== connect(DOMString address) ===
=== disconnect(DOMString address) ===
=== addService(BluetoothGattService service) ===
=== removeService(BluetoothGattService service) ===
=== clearServices() ===
=== close() ===
; Description
: The method closes GATT server instance.
; Return
: A Promise to indicate whether the operation is resolved or rejected.
=== notifyCharacteristicChanged(DOMString address, DOMString uuid, int instanceId, bool confirm) ===
=== sendResponse(DOMString address, int status, int requestId, ArrayBuffer value) ===

Revision as of 07:06, 20 November 2014

Overview

BluetoothGattServer provides bluetooth Generic Attribute Profile (GATT) server functionality to create Bluetooth Smart services and characteristics.

Interfaces

BluetoothGattServer

BluetoothGattServer

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

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

Properties

services

Description
Array of services offered by this device.
Value Type
sequence<BluetoothGattService>
Default Value
Empty array (array with length = 0)

Event Handlers

ondeviceconnectionstatechanged

onattributereadreq

Description
A handler to trigger when connection state of certain GATT client has changed.

onattributewritereq

onexecutewritereq

Methods

connect(DOMString address)

disconnect(DOMString address)

addService(BluetoothGattService service)

removeService(BluetoothGattService service)

clearServices()

close()

Description
The method closes GATT server instance.
Return
A Promise to indicate whether the operation is resolved or rejected.

notifyCharacteristicChanged(DOMString address, DOMString uuid, int instanceId, bool confirm)

sendResponse(DOMString address, int status, int requestId, ArrayBuffer value)