Version: Smart Feature Phone 2.5

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#

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.