Skip to main content

Bluetooth.BluetoothGattCharacteristic

Class

A characteristic of the Bluetooth GATT device.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported — Available on SPECS only
  • SPECSFully supported
  • Camera Kit WebNot supported — Available on SPECS only
  • Camera Kit MobileNot supported — Available on SPECS only

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not supported — Available on SPECS only.

Characteristics are the individual pieces of data within a Bluetooth.BluetoothGattService that provide specific information. For example, a heart rate sensor might have a Heart Rate service, and that service might have characteristics including "Heart Rate Measurement," "Sensor Location," etc.

Value (Bluetooth.BluetoothGattCharacteristic.readValue, Bluetooth.BluetoothGattCharacteristic.writeValue): The actual data being exchanged.

Properties (Bluetooth.BluetoothGattCharacteristic.properties): Define how the characteristic can be accessed (e.g., read, write, notify, indicate).

Descriptors ({Bluetooth.BluetoothGattCharacteristic.getDescriptor, Bluetooth.BluetoothGattCharacteristic.getDescriptors): Provide additional information about the characteristic, such as its units or format.

UUID (Bluetooth.BluetoothGattCharacteristic.uuid): A unique identifier that identifies the characteristic.

Common characteristics include battery level, heart rate, temperature, and device name.

Index

Extends

Properties

properties

readonly properties: CharacteristicProperty[]

ExperimentalSPECS

The supported properties (e.g., read, write) of the characteristic, as an Array of Bluetooth.CharacteristicProperty values.


uuid

readonly uuid: string

ExperimentalSPECS

The unique identifier of this characteristic.

Methods

getDescriptor()

getDescriptor(descriptorUUID): BluetoothGattDescriptor

ExperimentalSPECS

Retrieve a specific Bluetooth.BluetoothGattDescriptor by its UUID from this characteristic.

Parameters

ParameterType
descriptorUUIDstring

Returns

BluetoothGattDescriptor


getDescriptors()

getDescriptors(): BluetoothGattDescriptor[]

ExperimentalSPECS

Retrieve all descriptors associated with this characteristic.

Returns

BluetoothGattDescriptor[]


getTypeName()

static getTypeName(): TypeName<BluetoothGattCharacteristic>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<BluetoothGattCharacteristic>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame


readValue()

readValue(): Promise<Uint8Array<ArrayBufferLike>>

ExperimentalSPECS

Read and receive the current value of the characteristic.

Returns: The value in a Uint8Array

Returns

Promise<Uint8Array<ArrayBufferLike>>


registerNotifications()

registerNotifications(callback): Promise<void>

ExperimentalSPECS

Register the given callback to receive notifications. Registering a callback will unsubscribe any previous registration on this Characteristic.

callback The callback to register, which takes a single parameter value of type Uint8Array.

try {
const value = await characteristic.registerNotifications();
console.log("Received Uint8Array data: ", value);
} catch (error) {
console.error("Failed to register notifications: ", error);
}

Returns: Promise resolving to void when the callback is successfully registered.

Parameters

ParameterType
callback(value) => void

Returns

Promise<void>


unregisterNotifications()

unregisterNotifications(): Promise<void>

ExperimentalSPECS

Unregister all notifications.

Returns: Promise resolving to void when all notifications are successfully unregistered.

Returns

Promise<void>


writeValue()

writeValue(value): Promise<void>

ExperimentalSPECS

Write a new value to the characteristic.

value The value in a Uint8Array

Returns: Promise resolving to void when the value is successfully written.

Parameters

ParameterType
valueUint8Array

Returns

Promise<void>


writeValueWithoutResponse()

writeValueWithoutResponse(value): Promise<void>

ExperimentalSPECS

Write a new value to the characteristic without awaiting acknowledgment.

value The value in a Uint8Array

Parameters

ParameterType
valueUint8Array

Returns

Promise<void>