Lens Scripting API

    Class BluetoothGattCharacteristic

    A characteristic of the Bluetooth GATT device.

    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.

    Hierarchy (View Summary, Expand)

    Index

    Properties

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

    uuid: string

    The unique identifier of this characteristic.

    Methods

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

      Parameters

      • type: string

      Returns boolean

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

      Parameters

      Returns boolean

    • Experimental Wearable Only

      Read and receive the current value of the characteristic.

      Returns: The value in a Uint8Array

      Returns Promise<Uint8Array>

    • Experimental Wearable Only

      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

      • callback: (value: Uint8Array) => void

      Returns Promise<void>

    • Experimental Wearable Only

      Unregister all notifications.

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

      Returns Promise<void>

    • Experimental Wearable Only

      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

      • value: Uint8Array

      Returns Promise<void>

    • Experimental Wearable Only

      Write a new value to the characteristic without awaiting acknowledgment.

      value The value in a Uint8Array

      Parameters

      • value: Uint8Array

      Returns Promise<void>

    MMNEPVFCICPMFPCPTTAAATR