src.bluetooth_sig.registry.core.class_of_device¶
Registry for Class of Device decoding.
This module provides a registry for decoding 24-bit Class of Device (CoD) values from Classic Bluetooth into human-readable device classifications including major/minor device classes and service classes.
Attributes¶
Name | Description |
|---|---|
Classes¶
Name | Description |
|---|---|
Registry for Class of Device decoding with lazy loading. |
|
Bit masks for extracting Class of Device fields. |
|
Bit shift values for Class of Device fields. |
Module Contents¶
- class src.bluetooth_sig.registry.core.class_of_device.ClassOfDeviceRegistry¶
Bases:
bluetooth_sig.registry.base.BaseGenericRegistry[bluetooth_sig.types.registry.class_of_device.ClassOfDeviceInfo]Registry for Class of Device decoding with lazy loading.
This registry loads Class of Device mappings from the Bluetooth SIG assigned_numbers YAML file and provides methods to decode 24-bit CoD values into human-readable device classification information.
The registry uses lazy loading - the YAML file is only parsed on the first decode call. This improves startup time and reduces memory usage when the registry is not needed.
- CoD Structure (24 bits):
Bits 23-13: Service Class (11 bits, bit mask) Bits 12-8: Major Device Class (5 bits) Bits 7-2: Minor Device Class (6 bits) Bits 1-0: Format Type (always 0b00)
- Thread Safety:
This registry is thread-safe. Multiple threads can safely call decode_class_of_device() concurrently.
Example
>>> registry = ClassOfDeviceRegistry() >>> info = registry.decode_class_of_device(0x02010C) >>> print(info.full_description) # "Computer: Laptop (Networking)" >>> print(info.major_class) # "Computer" >>> print(info.minor_class) # "Laptop" >>> print(info.service_classes) # ["Networking"]
- decode_class_of_device(cod: int) bluetooth_sig.types.registry.class_of_device.ClassOfDeviceInfo¶
Decode 24-bit Class of Device value.
Extracts and decodes the major/minor device classes and service classes from a 24-bit CoD value. Lazy loads the registry data on first call.
- Parameters:
cod – 24-bit Class of Device value from advertising data
- Returns:
ClassOfDeviceInfo with decoded device classification
Examples
>>> registry = ClassOfDeviceRegistry() >>> # Computer (major=1), Laptop (minor=3), Networking service (bit 17) >>> info = registry.decode_class_of_device(0x02010C) >>> info.major_class 'Computer (desktop, notebook, PDA, organizer, ...)' >>> info.minor_class 'Laptop' >>> info.service_classes ['Networking (LAN, Ad hoc, ...)']
- class src.bluetooth_sig.registry.core.class_of_device.CoDBitMask¶
Bases:
enum.IntFlagBit masks for extracting Class of Device fields.
- CoD Structure (24 bits):
Bits 23-13: Service Class (11 bits, bit mask) Bits 12-8: Major Device Class (5 bits) Bits 7-2: Minor Device Class (6 bits) Bits 1-0: Format Type (always 0b00)
- FORMAT_TYPE = 3¶
- MAJOR_CLASS = 7936¶
- MINOR_CLASS = 252¶
- SERVICE_CLASS = 16769024¶
- class src.bluetooth_sig.registry.core.class_of_device.CoDBitShift¶
Bases:
enum.IntEnumBit shift values for Class of Device fields.
- MAJOR_CLASS = 8¶
- MINOR_CLASS = 2¶
- SERVICE_CLASS = 13¶
- src.bluetooth_sig.registry.core.class_of_device.class_of_device_registry¶