Bluetooth.BluetoothGattCharacteristic
ClassA 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
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
Properties
Methods
Extends
Properties
properties
readonlyproperties:CharacteristicProperty[]
ExperimentalSPECS
The supported properties (e.g., read, write) of the characteristic, as an Array of Bluetooth.CharacteristicProperty values.
uuid
readonlyuuid: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
| Parameter | Type |
|---|---|
descriptorUUID | string |
Returns
getDescriptors()
getDescriptors():
BluetoothGattDescriptor[]
ExperimentalSPECS
Retrieve all descriptors associated with this characteristic.
Returns
getTypeName()
staticgetTypeName():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
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
value | Uint8Array |
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
| Parameter | Type |
|---|---|
value | Uint8Array |
Returns
Promise<void>