src.bluetooth_sig.gatt.resolver

Shared SIG resolver utilities for characteristics and services.

This module provides common name resolution and normalization logic to avoid duplication between characteristic and service resolvers.

Attributes

Name

Description

TInfo

Classes

Name

Description

CharacteristicRegistrySearch

Registry search strategy for characteristics.

DescriptorRegistrySearch

Registry search strategy for descriptors.

NameNormalizer

Utilities for normalizing class names to various Bluetooth SIG formats.

NameVariantGenerator

Generates name variants for registry lookups.

RegistrySearchStrategy

Base strategy for searching registry with name variants.

ServiceRegistrySearch

Registry search strategy for services.

Module Contents

class src.bluetooth_sig.gatt.resolver.CharacteristicRegistrySearch

Bases: RegistrySearchStrategy[src.bluetooth_sig.types.CharacteristicInfo]

Registry search strategy for characteristics.

class src.bluetooth_sig.gatt.resolver.DescriptorRegistrySearch

Bases: RegistrySearchStrategy[src.bluetooth_sig.types.DescriptorInfo]

Registry search strategy for descriptors.

class src.bluetooth_sig.gatt.resolver.NameNormalizer

Utilities for normalizing class names to various Bluetooth SIG formats.

This class provides name transformation functions that are common to both characteristic and service resolution.

static camel_case_to_display_name(name: str) str

Convert camelCase class name to space-separated display name.

Uses regex to find word boundaries at capital letters and numbers.

Parameters:

name – CamelCase name (e.g., “VOCConcentration”, “BatteryLevel”, “ApparentEnergy32”)

Returns:

Space-separated display name (e.g., “VOC Concentration”, “Battery Level”, “Apparent Energy 32”)

Examples

>>> NameNormalizer.camel_case_to_display_name("VOCConcentration")
"VOC Concentration"
>>> NameNormalizer.camel_case_to_display_name("CO2Concentration")
"CO2 Concentration"
>>> NameNormalizer.camel_case_to_display_name("BatteryLevel")
"Battery Level"
>>> NameNormalizer.camel_case_to_display_name("ApparentEnergy32")
"Apparent Energy 32"
static remove_suffix(name: str, suffix: str) str

Remove suffix from name if present.

Parameters:
  • name – Original name

  • suffix – Suffix to remove (e.g., “Characteristic”, “Service”)

Returns:

Name without suffix, or original name if suffix not present

static snake_case_to_camel_case(s: str) str

Convert snake_case to CamelCase with acronym handling (for test file mapping).

static to_org_format(words: list[str], entity_type: str) str

Convert words to org.bluetooth format.

Parameters:
  • words – List of words from name split

  • entity_type – Type of entity (“characteristic” or “service”)

Returns:

Org format string (e.g., “org.bluetooth.characteristic.battery_level”)

class src.bluetooth_sig.gatt.resolver.NameVariantGenerator

Generates name variants for registry lookups.

Produces all possible name formats that might match registry entries, ordered by likelihood of success.

static generate_characteristic_variants(class_name: str, explicit_name: str | None = None) list[str]

Generate all name variants to try for characteristic resolution.

Parameters:
  • class_name – The __name__ of the characteristic class

  • explicit_name – Optional explicit name override

Returns:

List of name variants ordered by likelihood of success

static generate_descriptor_variants(class_name: str, explicit_name: str | None = None) list[str]

Generate all name variants to try for descriptor resolution.

Parameters:
  • class_name – The __name__ of the descriptor class

  • explicit_name – Optional explicit name override

Returns:

List of name variants ordered by likelihood of success

static generate_service_variants(class_name: str, explicit_name: str | None = None) list[str]

Generate all name variants to try for service resolution.

Parameters:
  • class_name – The __name__ of the service class

  • explicit_name – Optional explicit name override

Returns:

List of name variants ordered by likelihood of success

class src.bluetooth_sig.gatt.resolver.RegistrySearchStrategy

Bases: Generic[TInfo]

Base strategy for searching registry with name variants.

This class implements the Template Method pattern, allowing subclasses to customize the search behaviour for different entity types.

search(class_obj: type, explicit_name: str | None = None) TInfo | None

Search registry using name variants.

Parameters:
  • class_obj – The class to resolve info for

  • explicit_name – Optional explicit name override

Returns:

Resolved info object or None if not found

class src.bluetooth_sig.gatt.resolver.ServiceRegistrySearch

Bases: RegistrySearchStrategy[src.bluetooth_sig.types.ServiceInfo]

Registry search strategy for services.

src.bluetooth_sig.gatt.resolver.TInfo