{{ apiref("Web Bluetooth API") }} {{Non-standard_header()}}
The BluetoothGattCharacteristic
interface of the Web Bluetooth API represents a GATT Characteristic, which is a basic data element that provides further information about a peripheral’s service.
Interface
interface BluetoothGATTCharacteristic { readonly attribute BluetoothGATTService service; readonly attribute UUID uuid; readonly attribute BluetoothCharacteristicProperties properties; readonly attribute ArrayBuffer? value; Promise getDescriptor(BluetoothDescriptorUUID descriptor); Promise> getDescriptors(optional BluetoothDescriptorUUID descriptor); Promise readValue(); Promise writeValue(BufferSource value); Promise startNotifications(); Promise stopNotifications(); }; BluetoothGATTCharacteristic implements EventTarget; BluetoothGATTCharacteristic implements CharacteristicEventHandlers;
Properties
- {{domxref("BluetoothGATTCharacteristic.service")}} {{readonlyinline}}
- Returns the {{domxref("BluetoothGATTService")}} this characteristic belongs to.
- {{domxref("BluetoothGATTCharacteristic.uuid")}} {{readonlyinline}}
- Returns a {{domxref("DOMString")}} containing the UUID of the characteristic, for example
'00002a37-0000-1000-8000-00805f9b34fb'
for the Heart Rate Measurement characteristic. - {{domxref("BluetoothGATTCharacteristic.properties")}} {{readonlyinline}}
- Returns the properties of this characteristic.
- {{domxref("BluetoothGATTCharacteristic.value")}} {{readonlyinline}}
- The currently cached characteristic value. This value gets updated when the value of the characteristic is read or updated via a notification or indication.
Methods
- {{domxref("BluetoothGATTCharacteristic.getDescriptor()")}} {{readonlyinline}}
- Returns a {{jsxref("Promise")}} that resolves to the first {{domxref("BluetoothGATTDescriptor")}} for a given descriptor UUID.
- {{domxref("BluetoothGATTCharacteristic.getDescriptors()")}} {{readonlyinline}}
- Returns a {{jsxref("Promise")}} that resolves to an {{jsxref("Array")}} of all {{domxref("BluetoothGATTDescriptor")}} objects for a given descriptor UUID.
- {{domxref("BluetoothGATTCharacteristic.readValue()")}} {{readonlyinline}}
- Returns a {{jsxref("Promise")}} that resolves to an {{jsxref("ArrayBuffer")}} holding a duplicate of the
value
property if it is available and supported. Otherwise it throws an error. - {{domxref("BluetoothGATTCharacteristic.writeValue()")}} {{readonlyinline}}
- Sets the value property to the bytes contained in an {{jsxref("ArrayBuffer")}} and returns a {{jsxref("Promise")}}.
- {{domxref("BluetoothGATTCharacteristic.startNotifications()")}} {{readonlyinline}}
- Returns a {{jsxref("Promise")}} when
navigator.bluetooth
is added to the active notification context. - {{domxref("BluetoothGATTCharacteristic.stopNotifications()")}} {{readonlyinline}}
- Returns a {{jsxref("Promise")}} when
navigator.bluetooth
is removed from the active notification context.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('Web Bluetooth')}} | {{Spec2('Web Bluetooth')}} | Initial definition. |
Browser Compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome (45.0)}} [1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatNo}} |
[1] Behind a flag.