src.bluetooth_sig.types.company¶
Company identifier types for Bluetooth SIG manufacturer IDs.
Provides a unified type that encapsulates both the numeric company ID and its resolved human-readable name from the Bluetooth SIG registry.
Classes¶
Name | Description |
|---|---|
Bluetooth SIG company identifier with resolved name. |
|
Manufacturer-specific advertising data. |
Module Contents¶
- class src.bluetooth_sig.types.company.CompanyIdentifier¶
Bases:
msgspec.StructBluetooth SIG company identifier with resolved name.
Encapsulates both the numeric company ID and its resolved name, providing a single source of truth for manufacturer identification in advertising data.
- id¶
Numeric company identifier (16-bit unsigned integer).
- name¶
Resolved company name from Bluetooth SIG registry. Falls back to hex format if not found in registry.
Example
# Direct construction apple = CompanyIdentifier(id=0x004C, name=”Apple, Inc.”)
# Using factory method (recommended) apple = CompanyIdentifier.from_id(0x004C) assert apple.id == 0x004C assert apple.name == “Apple, Inc.”
# Unknown company ID unknown = CompanyIdentifier.from_id(0xFFFF) assert unknown.id == 0xFFFF assert unknown.name == “Unknown (0xFFFF)”
- classmethod from_id(company_id: int) CompanyIdentifier¶
Create CompanyIdentifier from numeric ID with registry lookup.
- Parameters:
company_id – Manufacturer company identifier (e.g., 0x004C for Apple).
- Returns:
CompanyIdentifier with resolved name from registry.
Example
>>> company = CompanyIdentifier.from_id(0x004C) >>> company.id 76 >>> company.name 'Apple, Inc.'
- class src.bluetooth_sig.types.company.ManufacturerData¶
Bases:
msgspec.StructManufacturer-specific advertising data.
- company¶
Resolved company identifier with ID and name.
- payload¶
Raw manufacturer-specific data bytes.
Example
# Parse from raw bytes mfr_data = ManufacturerData.from_bytes(b’x4Cx00x02x15…’) print(mfr_data.company.name) # “Apple, Inc.” print(mfr_data.payload.hex()) # “0215…”
- classmethod from_bytes(data: bytes) ManufacturerData¶
Parse manufacturer data from raw AD structure bytes.
- Parameters:
data – Raw bytes with company ID (little-endian uint16) followed by payload.
- Returns:
Parsed ManufacturerData with resolved company info.
- Raises:
ValueError – If data is too short to contain company ID.
- classmethod from_id_and_payload(company_id: int, payload: bytes) ManufacturerData¶
Create manufacturer data from company ID and payload.
- Parameters:
company_id – Numeric company identifier.
payload – Raw manufacturer-specific data bytes.
- Returns:
ManufacturerData with resolved company info.
- company: CompanyIdentifier¶