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

revise descriptor of readValue in GattCharacteristic
(revise descriptor of readValue in GattCharacteristic)
 
(12 intermediate revisions by 4 users not shown)
Line 4: Line 4:
== Interfaces ==
== Interfaces ==
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#BluetoothGattCharacteristic|BluetoothGattCharacteristic]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#BluetoothGattCharacteristic|BluetoothGattCharacteristic]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#Permissions|Permissions]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#GattPermissions|GattPermissions]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#Properties|Properties]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#GattCharacteristicProperties|GattCharacteristicProperties]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#WriteType|WriteType]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#WriteType|WriteType]]


Line 18: Line 18:
   readonly attribute unsigned short [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#instanceId|instanceId]];
   readonly attribute unsigned short [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#instanceId|instanceId]];
   readonly attribute ArrayBuffer? [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#value|value]];
   readonly attribute ArrayBuffer? [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#value|value]];
   [Cached, Constant] readonly attribute [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#Permissions|Permissions]] [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#properties_2|permissions]];
   [Cached, Constant] readonly attribute [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#GattPermissions|GattPermissions]] [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#permissions_2|permissions]];
   [Cached, Constant] readonly attribute [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#Properties|Properties]] [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#properties_2|properties]];
   [Cached, Constant] readonly attribute [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#GattCharacteristicProperties|GattCharacteristicProperties]] [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#properties_2|properties]];
   [Cached, Pure]              attribute [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#WriteType|WriteType]] [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#writeType|writeType]];
   [Cached, Pure]              attribute [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#WriteType|WriteType]] [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#writeType|writeType]];
   
   
   [NewObject, Throws] Promise<ArrayBuffer> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#readValue.28.29|readValue()]];
   [NewObject] Promise<ArrayBuffer> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#readValue.28.29|readValue()]];
   [NewObject, Throws] Promise<ArrayBuffer> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#writeValue.28ArrayBuffer value.29|writeValue(ArrayBuffer value)]];
   [NewObject] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#writeValue.28ArrayBuffer value.29|writeValue(ArrayBuffer value)]];
   [NewObject, Throws] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#startNotification.28.29|startNotifications()]];
   [NewObject] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#startNotifications.28.29|startNotifications()]];
   [NewObject, Throws] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#stopNotification.28.29|stopNotifications()]];
   [NewObject] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#stopNotifications.28.29|stopNotifications()]];
   [NewObject, Throws] Promise<[[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#BluetoothGattDescriptor|BluetoothGattDescriptor]]> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#addDescriptor.28DOMString_uuid.2C_Permissions_permissions.29|addDescriptor(DOMString uuid, Permissions permissions)]];
   [NewObject] Promise<[[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#BluetoothGattDescriptor|BluetoothGattDescriptor]]> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#addDescriptor.28DOMString_uuid.2C_GattPermissions_permissions.2C_ArrayBuffer_value.29|addDescriptor(DOMString uuid, GattPermissions permissions, ArrayBuffer value)]];
  };
  };


=== Permissions ===
=== GattPermissions ===
  dictionary Permissions
  dictionary GattPermissions
  {
  {
   required boolean read;
   boolean read = false;
   required boolean readEncrypted;
   boolean readEncrypted = false;
   required boolean readEncryptedMITM;
   boolean readEncryptedMITM = false;
   required boolean write;
   boolean write = false;
   required boolean writeEncrypted;
   boolean writeEncrypted = false;
   required boolean writeEncryptedMITM;
   boolean writeEncryptedMITM = false;
   required boolean writeSigned;
   boolean writeSigned = false;
   required boolean writeSignedMITM;
   boolean writeSignedMITM = false;
  };
  };


=== Properties ===
=== GattCharacteristicProperties ===
  dictionary Properties
  dictionary GattCharacteristicProperties
  {
  {
   required boolean broadcast;
   boolean broadcast = false;
   required boolean read;
   boolean read = false;
   required boolean writeNoResponse;
   boolean writeNoResponse = false;
   required boolean write;
   boolean write = false;
   required boolean notify;
   boolean notify = false;
   required boolean indicate;
   boolean indicate = false;
   required boolean signedWrite;
   boolean signedWrite = false;
   required boolean extendedProps;
   boolean extendedProps = false;
  };
  };


Line 63: Line 63:
  };
  };


== Properties ==
== GattCharacteristicProperties ==
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#service|BluetoothGattCharacteristic.service]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#service|BluetoothGattCharacteristic.service]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#descriptors|BluetoothGattCharacteristic.descriptors]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#descriptors|BluetoothGattCharacteristic.descriptors]]
Line 69: Line 69:
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#instanceId|BluetoothGattCharacteristic.instanceId]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#instanceId|BluetoothGattCharacteristic.instanceId]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#value|BluetoothGattCharacteristic.value]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#value|BluetoothGattCharacteristic.value]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#properties_2|BluetoothGattCharacteristic.permissions]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#permissions_2|BluetoothGattCharacteristic.permissions]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#properties_3|BluetoothGattCharacteristic.properties]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#properties_3|BluetoothGattCharacteristic.properties]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#writeType_2|BluetoothGattCharacteristic.writeType]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#writeType_2|BluetoothGattCharacteristic.writeType]]
Line 134: Line 134:


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


; Default Value
; Default Value
Line 145: Line 145:


; Value Type
; Value Type
: dictionary [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#Properties|Properties]]
: dictionary [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#GattCharacteristicProperties|GattCharacteristicProperties]]


; Default Value
; Default Value
Line 166: Line 166:
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#startNotifications.28.29|BluetoothGattCharacteristic.startNotifications()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#startNotifications.28.29|BluetoothGattCharacteristic.startNotifications()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#stopNotifications.28.29|BluetoothGattCharacteristic.stopNotifications()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#stopNotifications.28.29|BluetoothGattCharacteristic.stopNotifications()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#addDescriptor.28DOMString_uuid.2C_GattPermissions_permissions.2C_ArrayBuffer_value.29|addDescriptor(DOMString uuid, GattPermissions permissions, ArrayBuffer value)]]


=== readValue() ===
=== readValue() ===


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


; Return
; 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.
: 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) ===
=== writeValue(ArrayBuffer value) ===


; Description
; Description
: Write the characteristic value to the remote device.
: Write the characteristic 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/BluetoothGattCharacteristic#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. The Promise is resolved along with the characteristic value after this write operation.
: A Promise to indicate whether the operation is resolved or rejected.


=== startNotifications() ===
=== startNotifications() ===
Line 203: Line 204:
: A Promise to indicate whether the operation is resolved or rejected. The Promise is rejected if there is no Client Characteristic Configuration descriptor (CCCD) for this characteristic.
: A Promise to indicate whether the operation is resolved or rejected. The Promise is rejected if there is no Client Characteristic Configuration descriptor (CCCD) for this characteristic.


=== addDescriptor(DOMString uuid, Permissions permissions) ===
=== addDescriptor(DOMString uuid, GattPermissions permissions, ArrayBuffer value) ===


; Description
; Description
Line 212: Line 213:
:: UUID of the descriptor to add.
:: UUID of the descriptor to add.
: ''permissions''
: ''permissions''
:: permissions of the descriptor to add.
:: [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#GattPermissions|GattPermissions]] of the descriptor to add.
: ''value''
:: The initial value of this descriptor.


; Return
; Return
: A Promise to indicate whether the operation is resolved or rejected. If the Promise is resolved, it returns the added [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#BluetoothGattDescriptor|BluetoothGattDescriptor]], and the property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#descriptors|descriptors]] is also updated with the added descriptor.
: A Promise to indicate whether the operation is resolved or rejected. If the Promise is resolved, it returns the added [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattDescriptor#BluetoothGattDescriptor|BluetoothGattDescriptor]] object, and property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#descriptors|descriptors]] is also updated with the added descriptor.
120

edits