src.bluetooth_sig.gatt.characteristics.templates.domain

Domain-specific templates that compose scaled templates.

Covers TemperatureTemplate, ConcentrationTemplate, PressureTemplate.

Classes

Name

Description

ConcentrationTemplate

Template for concentration measurements with configurable resolution.

PressureTemplate

Template for pressure measurements (uint32, 0.1 Pa resolution).

TemperatureTemplate

Template for standard Bluetooth SIG temperature format (sint16, 0.01°C resolution).

Module Contents

class src.bluetooth_sig.gatt.characteristics.templates.domain.ConcentrationTemplate(resolution: float = 1.0)

Bases: src.bluetooth_sig.gatt.characteristics.templates.base.CodingTemplate[float]

Template for concentration measurements with configurable resolution.

Used for environmental sensors like CO2, VOC, particulate matter, etc.

decode_value(data: bytearray, offset: int = 0, ctx: src.bluetooth_sig.gatt.context.CharacteristicContext | None = None, *, validate: bool = True) float

Parse concentration with resolution.

encode_value(value: float, *, validate: bool = True) bytearray

Encode concentration value to bytes.

classmethod from_letter_method(M: int, d: int, b: int = 0) ConcentrationTemplate

Create instance using Bluetooth SIG M, d, b parameters.

Parameters:
  • M – Multiplier factor

  • d – Decimal exponent (10^d)

  • b – Offset to add to raw value before scaling

Returns:

ConcentrationTemplate instance

property data_size: int

2 bytes.

Type:

Size

property extractor: src.bluetooth_sig.gatt.characteristics.utils.extractors.RawExtractor

Get extractor from underlying scaled template.

property translator: src.bluetooth_sig.gatt.characteristics.utils.translators.ValueTranslator[float]

Return the linear translator from the underlying scaled template.

class src.bluetooth_sig.gatt.characteristics.templates.domain.PressureTemplate

Bases: src.bluetooth_sig.gatt.characteristics.templates.base.CodingTemplate[float]

Template for pressure measurements (uint32, 0.1 Pa resolution).

decode_value(data: bytearray, offset: int = 0, ctx: src.bluetooth_sig.gatt.context.CharacteristicContext | None = None, *, validate: bool = True) float

Parse pressure in 0.1 Pa resolution (returns Pa).

encode_value(value: float, *, validate: bool = True) bytearray

Encode pressure to bytes.

property data_size: int

4 bytes.

Type:

Size

property extractor: src.bluetooth_sig.gatt.characteristics.utils.extractors.RawExtractor

Get extractor from underlying scaled template.

property translator: src.bluetooth_sig.gatt.characteristics.utils.translators.ValueTranslator[float]

Return the linear translator from the underlying scaled template.

class src.bluetooth_sig.gatt.characteristics.templates.domain.TemperatureTemplate

Bases: src.bluetooth_sig.gatt.characteristics.templates.base.CodingTemplate[float]

Template for standard Bluetooth SIG temperature format (sint16, 0.01°C resolution).

decode_value(data: bytearray, offset: int = 0, ctx: src.bluetooth_sig.gatt.context.CharacteristicContext | None = None, *, validate: bool = True) float

Parse temperature in 0.01°C resolution.

encode_value(value: float, *, validate: bool = True) bytearray

Encode temperature to bytes.

property data_size: int

2 bytes.

Type:

Size

property extractor: src.bluetooth_sig.gatt.characteristics.utils.extractors.RawExtractor

Get extractor from underlying scaled template.

property translator: src.bluetooth_sig.gatt.characteristics.utils.translators.ValueTranslator[float]

Return the linear translator from the underlying scaled template.