src.bluetooth_sig.registry.uuids.units

Registry for Bluetooth SIG unit UUID metadata.

Loads unit definitions from the Bluetooth SIG units.yaml specification, providing UUID-to-name-to-symbol resolution. Used primarily for: - Resolving org.bluetooth.unit.* identifiers from GSS YAML files - Converting unit IDs to human-readable SI symbols for display

Note: This is distinct from the domain enums in types/units.py which provide type-safe unit representations for decoded characteristic data. The symbols derived here match those enum values for consistency.

Classes

Name

Description

UnitsRegistry

Registry for Bluetooth SIG unit UUIDs.

Functions

Name

Description

get_units_registry(→ UnitsRegistry)

Return the process-wide units_registry singleton instance.

resolve_unit_symbol(→ str)

Resolve a SIG unit identifier to its canonical symbol.

Module Contents

class src.bluetooth_sig.registry.uuids.units.UnitsRegistry

Bases: bluetooth_sig.registry.base.BaseUUIDRegistry[bluetooth_sig.types.registry.units.UnitInfo]

Registry for Bluetooth SIG unit UUIDs.

get_all_units() list[bluetooth_sig.types.registry.units.UnitInfo]

Get all registered units.

Returns:

List of all UnitInfo objects

get_unit_info(uuid: str | bluetooth_sig.types.uuid.BluetoothUUID) bluetooth_sig.types.registry.units.UnitInfo | None

Get unit information by UUID.

Parameters:

uuid – 16-bit UUID as string (with or without 0x) or BluetoothUUID

Returns:

UnitInfo object, or None if not found

get_unit_info_by_id(unit_id: str) bluetooth_sig.types.registry.units.UnitInfo | None

Get unit information by ID.

Parameters:

unit_id – Unit ID (e.g., “org.bluetooth.unit.celsius”)

Returns:

UnitInfo object, or None if not found

get_unit_info_by_name(name: str) bluetooth_sig.types.registry.units.UnitInfo | None

Get unit information by name.

Parameters:

name – Unit name (case-insensitive)

Returns:

UnitInfo object, or None if not found

is_unit_uuid(uuid: str | bluetooth_sig.types.uuid.BluetoothUUID) bool

Check if a UUID is a registered unit UUID.

Parameters:

uuid – UUID to check

Returns:

True if the UUID is a unit UUID, False otherwise

src.bluetooth_sig.registry.uuids.units.get_units_registry() UnitsRegistry

Return the process-wide units_registry singleton instance.

src.bluetooth_sig.registry.uuids.units.resolve_unit_symbol(unit_id: str) str

Resolve a SIG unit identifier to its canonical symbol.

Accepts both short-form (thermodynamic_temperature.degree_celsius) and full-form (org.bluetooth.unit.thermodynamic_temperature.degree_celsius) identifiers, normalises to full-form, and looks up the symbol via units_registry.

Parameters:

unit_id – Unit identifier (short or full form).

Returns:

SI symbol string (e.g. '°C', 'bpm'), or empty string if the identifier cannot be resolved.