B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService: Difference between revisions
< B2G | Bluetooth | WebBluetooth-v2
Jump to navigation
Jump to search
(→Interfaces: Refine the contructor of BluetoothGattService by adding BluetoothGattServiceInit definition.) |
(Rename Permissions as GattPermissions.) |
||
| Line 18: | Line 18: | ||
readonly attribute unsigned short [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#instanceId|instanceId]]; | readonly attribute unsigned short [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#instanceId|instanceId]]; | ||
[NewObject] Promise<[[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#BluetoothGattCharacteristic|BluetoothGattCharacteristic]]> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#addCharacteristic.28DOMString_uuid. | [NewObject] Promise<[[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#BluetoothGattCharacteristic|BluetoothGattCharacteristic]]> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#addCharacteristic.28DOMString_uuid.2C_GattPermissions_permissions.2C_Properties_properties.2C_ArrayBuffer_value.29|addCharacteristic(DOMString uuid, GattPermissions permissions, Properties properties, ArrayBuffer value)]]; | ||
[NewObject] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#addIncludedService.28BluetoothGattService_service.29|addIncludedService(BluetoothGattService service)]]; | [NewObject] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#addIncludedService.28BluetoothGattService_service.29|addIncludedService(BluetoothGattService service)]]; | ||
}; | }; | ||
| Line 92: | Line 92: | ||
== Methods == | == Methods == | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#addCharacteristic.28DOMString_uuid. | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#addCharacteristic.28DOMString_uuid.2C_GattPermissions_permissions.2C_Properties_properties.29|BluetoothGattService.addCharacteristic(DOMString uuid, GattPermissions permissions, Properties properties, ArrayBuffer value)]] | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#addIncludedService.28BluetoothGattService_service.29|BluetoothGattService.addIncludedService(BluetoothGattService service)]] | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#addIncludedService.28BluetoothGattService_service.29|BluetoothGattService.addIncludedService(BluetoothGattService service)]] | ||
=== addCharacteristic(DOMString uuid, | === addCharacteristic(DOMString uuid, GattPermissions permissions, Properties properties, ArrayBuffer value) === | ||
; Description | ; Description | ||
| Line 104: | Line 104: | ||
:: UUID of the characteristic to add. | :: UUID of the characteristic to add. | ||
: ''permissions'' | : ''permissions'' | ||
:: [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic# | :: [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#GattPermissions|GattPermissions]] of the characteristic to add. | ||
: ''properties'' | : ''properties'' | ||
:: [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#Properties|Properties]] of the characteristic to add | :: [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#Properties|Properties]] of the characteristic to add | ||
Revision as of 06:48, 17 August 2015
Overview
BluetoothGattService represents the service provided by GATT server. BluetoothGattService consists of the service definition, a list of included services which this service references, and a list of characteristics in this service.
Interfaces
BluetoothGattService
[CheckPermissions="bluetooth",
Constructor(BluetoothGattServiceInit init)]
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 unsigned short instanceId;
[NewObject] Promise<BluetoothGattCharacteristic> addCharacteristic(DOMString uuid, GattPermissions permissions, Properties properties, ArrayBuffer value);
[NewObject] Promise<void> addIncludedService(BluetoothGattService service);
};
BluetoothGattServiceInit
dictionary BluetoothGattServiceInit
{
boolean isPrimary = false;
DOMString uuid = "";
};
Properties
- BluetoothGattService.characteristics
- BluetoothGattService.includedServices
- BluetoothGattService.isPrimary
- BluetoothGattService.uuid
- BluetoothGattService.instanceId
characteristics
- Description
- A cached array of charactertistics contained in this service.
- Value Type
- sequence<BluetoothGattCharacteristic>
- Default Value
- 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
- unsigned short
- Default Value
- 0
Methods
- BluetoothGattService.addCharacteristic(DOMString uuid, GattPermissions permissions, Properties properties, ArrayBuffer value)
- BluetoothGattService.addIncludedService(BluetoothGattService service)
addCharacteristic(DOMString uuid, GattPermissions permissions, Properties properties, ArrayBuffer value)
- Description
- The method adds a characteristic to this service.
- Parameter
- uuid
- UUID of the characteristic to add.
- permissions
- GattPermissions of the characteristic to add.
- properties
- Properties of the characteristic to add
- value
- The initial value of this characteristic.
- Return
- A Promise to indicate whether the operation is resolved or rejected. Once the Promise is resolved, the property characteristics is also updated with the added characteristic.
addIncludedService(BluetoothGattService service)
- Description
- The method adds an included service to this service.
- Parameter
- service
- The BluetoothGattService object to add.
- Return
- A Promise to indicate whether the operation is resolved or rejected. Once the Promise is resolved, it returns the added BluetoothGattService object, and property includedServices is also updated with the added service.