Version: Smart Feature Phone 3.0

BluetoothGattCharacteristic

Description#

The BluetoothGattCharacteristic interface of the Bluetooth API represents a GATT service characteristic, which includes characteristic definition, value, properties and configuration info, and a list of descriptors that provide related information.

Interface overview#

[CheckAnyPermissions="bluetooth"]
interface BluetoothGattCharacteristic
{
readonly attribute BluetoothGattService service;
[Cached, Pure] readonly attribute sequence<BluetoothGattDescriptor> descriptors;
readonly attribute DOMString uuid;
readonly attribute unsigned short instanceId;
readonly attribute ArrayBuffer? value;
[Cached, Constant] readonly attribute Permissions permissions;
[Cached, Constant] readonly attribute GattCharacteristicProperties properties;
[NewObject] Promise<ArrayBuffer> readValue();
[NewObject] Promise<void> writeValue(ArrayBuffer value);
[NewObject] Promise<void> startNotifications();
[NewObject] Promise<void> stopNotifications();
[NewObject] Promise<BluetoothGattDescriptor> addDescriptor(DOMString uuid, Permissions permissions, ArrayBuffer value);
};

Properties#

  • BluetoothGattCharacteristic.service

      Returns the BluetoothGattService that this characteristic belongs to.

  • BluetoothGattCharacteristic.descriptors

      Returns a cached array containing the BluetoothGattDescriptor objects that describe this characteristic.

  • BluetoothGattCharacteristic.uuid

      Returns a DOMString representing the UUID of this characteristic.

  • BluetoothGattCharacteristic.instanceId

      Returns a number representing the instance id of this characteristic.

  • BluetoothGattCharacteristic.value

      Returns The cached value of this characteristic. This value can be updated via the BluetoothGattCharacteristic.readValue() method, characteristic notification, or indication from the remote device.

  • BluetoothGattCharacteristic.permissions

      Returns a bit mask that describes the operations permitted on this characteristic.

  • BluetoothGattCharacteristic.properties

      Returns a bit mask that describes how to use the characteristic value.

Methods#

  • BluetoothGattCharacteristic.readValue()

      Reads the characteristic value from the remote device. The cached value property will also be updated after retrieving the value.

  • BluetoothGattCharacteristic.writeValue()

      Writes 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 BluetoothGattCharacteristic.value.

  • BluetoothGattCharacteristic.startNotifications()

      Registers notifications/indications for this characteristic.

  • BluetoothGattCharacteristic.stopNotifications()

      Unregisters notifications/indications for this characteristic.

  • BluetoothGattCharacteristic.addDescriptor()

      Adds a descriptor to this characteristic.