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

From MozillaWiki
Jump to navigation Jump to search
No edit summary
Line 10: Line 10:
  {
  {
   [Cached, Pure]
   [Cached, Pure]
   readonly attribute sequence<[[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic|BluetoothGattCharacteristic]]> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#characteristics|characteristics]];
   readonly attribute sequence<[[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#BluetoothGattCharacteristic|BluetoothGattCharacteristic]]> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#characteristics|characteristics]];
   [Cached, Pure]
   [Cached, Pure]
   readonly attribute sequence<[[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService|BluetoothGattService]]>    [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#includedServices|includedServices]];
   readonly attribute sequence<[[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#BluetoothGattService|BluetoothGattService]]>    [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#includedServices|includedServices]];
   readonly attribute boolean                              [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#isPrimary|isPrimary]];
   readonly attribute boolean                              [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#isPrimary|isPrimary]];
   readonly attribute DOMString                            [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#uuid|uuid]];
   readonly attribute DOMString                            [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#uuid|uuid]];
   readonly attribute int                                  [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#instanceId|instanceId]];
   readonly attribute int                                  [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#instanceId|instanceId]];
   
   
   [NewObject, Throws]
   [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic|BluetoothGattCharacteristic]]? [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#findCharacteristic.28DOMString uuid.29|findCharacteristic(DOMString uuid)]];
  Promise<[[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic|BluetoothGattCharacteristic]]> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#findCharacteristic.28DOMString uuid.29|findCharacteristic(DOMString uuid)]];
  };
  };


Line 89: Line 88:


; Description
; Description
: The method finds a characteristic in this service by the given UUID.
: The method finds a characteristic in this service from the characteristics property by the given UUID.
: When there are multiple characteristics with the same UUID existed in the service, the first one will be returned.
: When there are multiple characteristics with the same UUID existed in the service, the first one will be returned.


Line 97: Line 96:


; Return
; Return
: A Promise to indicate whether the operation is resolved or rejected. If the Promise is resolved, it returns the target characteristic.
: The first characteristic with the given uuid in characteristics property.
: The Promise will be rejected if no characteristic with the given UUID is found.
: A null ptr is returned if no characteristic is found.


; Sample
; Sample
: TBD
: TBD

Revision as of 05:20, 22 August 2014

Overview

BluetoothGattService represents the service provided by GATT server. BluetoothGattService is consisted of its service definition, a list of included services which are referenced by this service, and a list of characteristics in this service.

Interfaces

BluetoothGattService

BluetoothGattService

[CheckPermissions="bluetooth"]
interface BluetoothGattService
{
  [Cached, Pure]
  readonly attribute sequence<BluetoothGattCharacteristic> characteristics;
  [Cached, Pure]
  readonly attribute sequence<BluetoothGattService>     includedServices;
  readonly attribute boolean                               isPrimary;
  readonly attribute DOMString                             uuid;
  readonly attribute int                                   instanceId;

  BluetoothGattCharacteristic? findCharacteristic(DOMString uuid);
};

Properties

characteristics

Description
A cached array of charactertistics contained in this service.
Value Type
sequence<BluetoothGattCharacteristic>
Default Value
An empty array. (array with length = 0)

includedServices

Description
A cached array of included services referenced by this service.
Value Type
sequence<BluetoothGattService>
Default Value
Empty array (array with length = 0)

isPrimary

Description
Indicate whether this is a primary or secondary service.
Value Type
boolean
Default Value
false

uuid

Description
This property stores the UUID of this service.
Value Type
DOMString
Default Value
Empty string ("")

instanceId

Description
This property stores the instance id of this service.
Value Type
interger
Default Value
0

Methods

findCharacteristic(DOMString uuid)

Description
The method finds a characteristic in this service from the characteristics property by the given UUID.
When there are multiple characteristics with the same UUID existed in the service, the first one will be returned.
Parameters
uuid
UUID DOMString of the characteristic to seek for.
Return
The first characteristic with the given uuid in characteristics property.
A null ptr is returned if no characteristic is found.
Sample
TBD