src.bluetooth_sig.types.units

Domain enums for measurement units in decoded characteristic data.

These enums provide type-safe representations of measurement choices (e.g., Celsius vs Fahrenheit, metric vs imperial) used in decoded characteristic return values. They enable static type checking and IDE autocompletion for unit-aware data.

Note: These are distinct from UnitInfo in registry/uuids/units.py which provides Bluetooth SIG metadata (UUID, name, symbol) loaded from YAML. The symbol values here intentionally match the registry symbols for consistency, but serve different purposes: - Domain enums: Type hints for decoded data (e.g., unit: PressureUnit) - Registry UnitInfo: UUID resolution and metadata lookup

Reference: https://www.bipm.org/en/measurement-units

Classes

Name

Description

AngleUnit

Units for angle measurements.

ConcentrationUnit

Units for concentration measurements.

ElectricalUnit

Units for electrical measurements.

GlucoseConcentrationUnit

Units for glucose concentration measurements.

HeightUnit

Units for height measurements.

LengthUnit

Units for length measurements.

MeasurementSystem

Measurement system for body composition and weight data.

PercentageUnit

Units for percentage measurements.

PhysicalUnit

Units for physical measurements.

PressureUnit

Units for pressure measurements.

SoundUnit

Units for sound measurements.

SpecialValueType

Standard Bluetooth SIG special value categories.

TemperatureUnit

Units for temperature measurements.

WeightUnit

Units for weight/mass measurements.

Functions

Name

Description

classify_special_value(→ SpecialValueType)

Classify a GSS meaning string into a standard category.

Module Contents

class src.bluetooth_sig.types.units.AngleUnit(*args, **kwds)

Bases: enum.Enum

Units for angle measurements.

DEGREES = '°'
class src.bluetooth_sig.types.units.ConcentrationUnit(*args, **kwds)

Bases: enum.Enum

Units for concentration measurements.

GRAINS_PER_CUBIC_METER = 'grains/m³'
KILOGRAMS_PER_CUBIC_METER = 'kg/m³'
MICROGRAMS_PER_CUBIC_METER = 'µg/m³'
PARTS_PER_BILLION = 'ppb'
PARTS_PER_MILLION = 'ppm'
class src.bluetooth_sig.types.units.ElectricalUnit(*args, **kwds)

Bases: enum.Enum

Units for electrical measurements.

AMPS = 'A'
DBM = 'dBm'
HERTZ = 'Hz'
VOLTS = 'V'
class src.bluetooth_sig.types.units.GlucoseConcentrationUnit(*args, **kwds)

Bases: enum.Enum

Units for glucose concentration measurements.

MG_DL = 'mg/dL'
MMOL_L = 'mmol/L'
class src.bluetooth_sig.types.units.HeightUnit(*args, **kwds)

Bases: enum.Enum

Units for height measurements.

INCHES = 'inches'
METERS = 'meters'
class src.bluetooth_sig.types.units.LengthUnit(*args, **kwds)

Bases: enum.Enum

Units for length measurements.

INCHES = "'"
METERS = 'm'
MILLIMETERS = 'mm'
class src.bluetooth_sig.types.units.MeasurementSystem(*args, **kwds)

Bases: enum.Enum

Measurement system for body composition and weight data.

IMPERIAL = 'imperial'
METRIC = 'metric'
class src.bluetooth_sig.types.units.PercentageUnit(*args, **kwds)

Bases: enum.Enum

Units for percentage measurements.

PERCENT = '%'
class src.bluetooth_sig.types.units.PhysicalUnit(*args, **kwds)

Bases: enum.Enum

Units for physical measurements.

TESLA = 'T'
class src.bluetooth_sig.types.units.PressureUnit(*args, **kwds)

Bases: enum.Enum

Units for pressure measurements.

KPA = 'kPa'
MMHG = 'mmHg'
class src.bluetooth_sig.types.units.SoundUnit(*args, **kwds)

Bases: enum.Enum

Units for sound measurements.

DECIBELS_SPL = 'dB SPL'
class src.bluetooth_sig.types.units.SpecialValueType(*args, **kwds)

Bases: enum.Enum

Standard Bluetooth SIG special value categories.

These represent sentinel values in characteristic data that indicate the measurement is not a normal reading. GSS YAML files define these using patterns like “value is not known” or “value is not valid”.

INVALID = 'invalid'
OUT_OF_RANGE = 'out_of_range'
OVERFLOW = 'overflow'
UNDERFLOW = 'underflow'
UNKNOWN = 'unknown'
class src.bluetooth_sig.types.units.TemperatureUnit(*args, **kwds)

Bases: enum.Enum

Units for temperature measurements.

CELSIUS = '°C'
FAHRENHEIT = '°F'
class src.bluetooth_sig.types.units.WeightUnit(*args, **kwds)

Bases: enum.Enum

Units for weight/mass measurements.

KG = 'kg'
LB = 'lb'
src.bluetooth_sig.types.units.classify_special_value(meaning: str) SpecialValueType

Classify a GSS meaning string into a standard category.

Parses the human-readable meaning from GSS YAML special value definitions and maps it to a SpecialValueType enum.

Parameters:

meaning – Human-readable meaning from GSS (e.g., “value is not known”)

Returns:

The appropriate SpecialValueType category.