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

From MozillaWiki
Jump to navigation Jump to search
(Created page with "== Overview == TBD == Interfaces == BluetoothGattDescriptor === BluetoothGattDescriptor ===...")
 
(revise description of readValue in GattDescriptor)
 
(19 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Overview ==
== Overview ==
TBD
'''BluetoothGattDescriptor''' represents a GATT descriptor, which contains related information about a characteristic value.


== Interfaces ==
== Interfaces ==
Line 9: Line 9:
  interface BluetoothGattDescriptor
  interface BluetoothGattDescriptor
  {
  {
   // Permission
   readonly attribute [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#BluetoothGattCharacteristic|BluetoothGattCharacteristic]] [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#characteristic|characteristic]];
  const unsigned short PERMISSION_READ              = 0x0001;
   readonly attribute DOMString [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#uuid|uuid]];
   const unsigned short PERMISSION_READ_ENCRYPTED    = 0x0002;
   readonly attribute ArrayBuffer? [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#value|value]];
   const unsigned short PERMISSION_READ_ENC_MITM    = 0x0004;
   [Cached, Constant] readonly attribute [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#GattPermissions|GattPermissions]] [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#permissions|permissions]];
   const unsigned short PERMISSION_WRITE            = 0x0010;
  const unsigned short PERMISSION_WRITE_ENCRYPTED  = 0x0020;
  const unsigned short PERMISSION_WRITE_ENC_MITM    = 0x0040;
  const unsigned short PERMISSION_WRITE_SIGNED      = 0x0080;
  const unsigned short PERMISSION_WRITE_SIGNED_MITM = 0x0100;
   
   
  readonly attribute [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#BluetoothGattCharacteristic|BluetoothGattCharacteristic]]                  [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#characteristic|characteristic]];
   [NewObject] Promise<ArrayBuffer> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#readValue.28.29|readValue()]];
  readonly attribute DOMString                            [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#uuid|uuid]];
   [NewObject] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#writeValue.28ArrayBuffer value.29|writeValue(ArrayBuffer value)]];
  readonly attribute int                                  [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#permissions|permissions]];
  readonly attribute ArrayBuffer?                          [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#value|value]];
   [NewObject, Throws]
  Promise<ArrayBuffer> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#readValue.28.29|readValue()]];
   [NewObject, Throws]
  Promise<ArrayBuffer> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#writeValue.28ArrayBuffer value.29|writeValue(ArrayBuffer value)]];
  };
  };


Line 33: Line 21:
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#characteristic|BluetoothGattDescriptor.characteristic]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#characteristic|BluetoothGattDescriptor.characteristic]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#uuid|BluetoothGattDescriptor.uuid]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#uuid|BluetoothGattDescriptor.uuid]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#value|BluetoothGattDescriptor.value]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#permissions|BluetoothGattDescriptor.permissions]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#permissions|BluetoothGattDescriptor.permissions]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#value|BluetoothGattDescriptor.value]]


=== characteristic ===
=== characteristic ===
Line 58: Line 46:
: Empty string ("")
: Empty string ("")


=== permissions ===
=== value ===


; Description
; Description
: A bit mask which describes the security level required for read/write accesses of this descriptor.
: The cached value of this descriptor.
: This value can be updated via readValue() method.


; Value Type
; Value Type
: integer
: ArrayBuffer or null


; Default Value
; Default Value
: 0
: null pointer


=== value ===
=== permissions ===


; Description
; Description
: The cached value of this descriptor.
: A bit mask which describes allowed operations on the characteristic.
: This value can be updated via readValue() method.


; Value Type
; Value Type
: ArrayBuffer or null
: dictionary [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#GattPermissions|GattPermissions]]


; Default Value
; Default Value
: null pointer
: 0


== Methods ==
== Methods ==
Line 88: Line 76:


; Description
; Description
: Read the descriptor value from GATT server.
: Read the descriptor value from either remote device (client role) or the local device (server role). In client mode, the cached value property is also updated after retrieving the value from the remote GATT server.
: The cached value property will also be updated after retrieving the value from server.


; Return
; Return
: A Promise to indicate whether the operation is resolved or rejected.
: A Promise to indicate whether the operation is resolved or rejected. The Promise is resolved along with the value retrieved from the remote device or local device.
: The Promise is resolved along with the value retrieved from GATT server.


=== writeValue(ArrayBuffer value) ===
=== writeValue(ArrayBuffer value) ===


; Description
; Description
: Write the descriptor value to the remote device.
: Write the descriptor value to the GATT server. If the local device is the GATT client, the value will be written to the remote GATT server. On the other hand, if the local device is the GATT server, the value will be written to [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#value|value]].


; Parameter
; Parameter
: ''value''
: ''value''
:: Desired value to be written to the remote device.
:: Desired value to be written to the GATT server.


; Return
; Return
: A Promise to indicate whether the operation is resolved or rejected.
: A Promise to indicate whether the operation is resolved or rejected. The Promise is resolved along with the descriptor value after this write operation.
: The Promise is resolved along with the descriptor value after this write operation.

Latest revision as of 09:32, 9 September 2015

Overview

BluetoothGattDescriptor represents a GATT descriptor, which contains related information about a characteristic value.

Interfaces

BluetoothGattDescriptor

BluetoothGattDescriptor

[CheckPermissions="bluetooth"]
interface BluetoothGattDescriptor
{
  readonly attribute BluetoothGattCharacteristic characteristic;
  readonly attribute DOMString uuid;
  readonly attribute ArrayBuffer? value;
  [Cached, Constant] readonly attribute GattPermissions permissions;

  [NewObject] Promise<ArrayBuffer> readValue();
  [NewObject] Promise<void> writeValue(ArrayBuffer value);
};

Properties

characteristic

Description
The characteristic which this descriptor belongs to.
Value Type
BluetoothGattCharacteristic
Default Value
null pointer

uuid

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

value

Description
The cached value of this descriptor.
This value can be updated via readValue() method.
Value Type
ArrayBuffer or null
Default Value
null pointer

permissions

Description
A bit mask which describes allowed operations on the characteristic.
Value Type
dictionary GattPermissions
Default Value
0

Methods

readValue()

Description
Read the descriptor value from either remote device (client role) or the local device (server role). In client mode, the cached value property is also updated after retrieving the value from the remote GATT server.
Return
A Promise to indicate whether the operation is resolved or rejected. The Promise is resolved along with the value retrieved from the remote device or local device.

writeValue(ArrayBuffer value)

Description
Write the descriptor value to the GATT server. If the local device is the GATT client, the value will be written to the remote GATT server. On the other hand, if the local device is the GATT server, the value will be written to value.
Parameter
value
Desired value to be written to the GATT server.
Return
A Promise to indicate whether the operation is resolved or rejected. The Promise is resolved along with the descriptor value after this write operation.