src.bluetooth_sig.gatt.descriptors.characteristic_presentation_format

Characteristic Presentation Format Descriptor implementation.

Classes

Name

Description

CharacteristicPresentationFormatData

Characteristic Presentation Format descriptor data.

CharacteristicPresentationFormatDescriptor

Characteristic Presentation Format Descriptor (0x2904).

FormatNamespace

Format namespace values for Characteristic Presentation Format.

FormatType

Format type values for Characteristic Presentation Format.

Module Contents

class src.bluetooth_sig.gatt.descriptors.characteristic_presentation_format.CharacteristicPresentationFormatData

Bases: msgspec.Struct

Characteristic Presentation Format descriptor data.

Raw integer values are preserved for protocol compatibility. Resolved names are provided when available via registry lookups.

description: int

Description identifier within the namespace.

description_name: str | None = None

Resolved description name (e.g., ‘left’, ‘first’) from NamespaceDescriptionRegistry.

Only resolved when namespace=0x01 (Bluetooth SIG Assigned Numbers).

exponent: int

Base 10 exponent for scaling (-128 to 127).

format: FormatType

Format type value (e.g., FormatType.UINT16).

format_name: str | None = None

Resolved format type name (e.g., ‘uint16’) from FormatTypesRegistry.

namespace: FormatNamespace

Namespace for description field (e.g., FormatNamespace.BLUETOOTH_SIG_ASSIGNED_NUMBERS).

unit: int

Raw unit UUID value (16-bit short form, e.g., 0x272F for Celsius).

unit_name: str | None = None

Resolved unit name (e.g., ‘degree Celsius’) from UnitsRegistry.

class src.bluetooth_sig.gatt.descriptors.characteristic_presentation_format.CharacteristicPresentationFormatDescriptor

Bases: src.bluetooth_sig.gatt.descriptors.base.BaseDescriptor

Characteristic Presentation Format Descriptor (0x2904).

Describes how characteristic values should be presented to users. Contains format, exponent, unit, namespace, and description information.

get_description(data: bytes) int

Get the description identifier.

get_exponent(data: bytes) int

Get the exponent for scaling.

get_format_type(data: bytes) FormatType

Get the format type.

get_namespace(data: bytes) FormatNamespace

Get the namespace identifier.

get_unit(data: bytes) int

Get the unit identifier.

class src.bluetooth_sig.gatt.descriptors.characteristic_presentation_format.FormatNamespace

Bases: enum.IntEnum

Format namespace values for Characteristic Presentation Format.

BLUETOOTH_SIG_ASSIGNED_NUMBERS = 1
RESERVED = 2
UNKNOWN = 0
class src.bluetooth_sig.gatt.descriptors.characteristic_presentation_format.FormatType

Bases: enum.IntEnum

Format type values for Characteristic Presentation Format.

BOOLEAN = 1
DUINT16 = 24
FLOAT = 23
FLOAT32 = 20
FLOAT64 = 21
SFLOAT = 22
SINT12 = 13
SINT128 = 19
SINT16 = 14
SINT24 = 15
SINT32 = 16
SINT48 = 17
SINT64 = 18
SINT8 = 12
STRUCT = 27
UINT12 = 5
UINT128 = 11
UINT16 = 6
UINT2 = 2
UINT24 = 7
UINT32 = 8
UINT4 = 3
UINT48 = 9
UINT64 = 10
UINT8 = 4
UNKNOWN = 0
UTF16S = 26
UTF8S = 25