src.bluetooth_sig.types.advertising¶
BLE Advertising data types and parsing utilities.
- Organization:
Core PDU Types and Enums - Low-level PDU structure definitions
Advertising Data Type Registry - AD Type metadata
Advertising Flags - Device discovery and capabilities flags
PDU and Header Structures - Structured PDU representations
Parsed Advertising Data - High-level parsed advertisement content
Classes¶
Name | Description |
|---|---|
Complete parsed advertisement with PDU structures and interpreted data. |
|
Complete BLE advertising data with device information and metadata. |
|
Complete parsed advertising data structures organized by category. |
|
BLE Advertising Flags (Core Spec Supplement, Part A, Section 1.3). |
|
BLE Advertising PDU structure. |
|
Extended Advertising Header fields (BLE 5.0+). |
|
Core advertising data - device identification and services. |
|
Device capability and appearance properties. |
|
Directed advertising and timing parameters. |
|
Extended advertising PDU-level metadata (BLE 5.0+). |
|
Extended advertising header field presence flags (BLE 5.0+). |
|
Location, positioning, and sensing related data. |
|
Bluetooth Mesh and audio broadcast related data. |
|
Out-of-Band (OOB) security data advertised for pairing. |
|
BLE PDU header bit masks for parsing operations. |
|
BLE PDU structure size and offset constants. |
|
BLE Advertising PDU Types (Core Spec Vol 6, Part B, Section 2.3). |
|
Security and encryption related advertising data. |
Module Contents¶
- class src.bluetooth_sig.types.advertising.AdvertisementData¶
Bases:
msgspec.StructComplete parsed advertisement with PDU structures and interpreted data.
This is the unified result from Device.update_advertisement(), containing both low-level AD structures and high-level vendor-specific interpretation.
The interpreted_data field is typed as Any to maintain msgspec.Struct compatibility while supporting generic vendor-specific result types at runtime.
- ad_structures¶
Parsed AD structures (manufacturer_data, service_data, etc.)
- interpreted_data¶
Vendor-specific typed result (e.g., sensor readings), or None
- interpreter_name¶
Name of the interpreter used (e.g., “BTHome”, “Xiaomi”), or None
- rssi¶
Received signal strength indicator in dBm
Example
# Using connection manager (recommended) ad_data = BleakConnectionManager.convert_advertisement(bleak_advertisement) result = device.update_advertisement(ad_data)
# Access low-level AD structures print(result.ad_structures.core.manufacturer_data) # {0x0499: b’…’} print(result.ad_structures.properties.flags)
# Access vendor-specific interpreted data if result.interpreted_data:
print(f”Interpreter: {result.interpreter_name}”) print(f”Temperature: {result.interpreted_data.temperature}”)
- ad_structures: AdvertisingDataStructures¶
- interpreted_data: Any = None¶
- property manufacturer_data: dict[int, bytes]¶
Convenience accessor for manufacturer data (company_id → payload).
- property service_data: dict[bluetooth_sig.types.uuid.BluetoothUUID, bytes]¶
Convenience accessor for service data (UUID → payload).
- class src.bluetooth_sig.types.advertising.AdvertisingData¶
Bases:
msgspec.StructComplete BLE advertising data with device information and metadata.
- raw_data¶
Raw bytes from the advertising packet
- ad_structures¶
Parsed AD structures organized by category
- extended¶
Extended advertising data (BLE 5.0+)
- rssi¶
Received signal strength indicator in dBm
- ad_structures: AdvertisingDataStructures¶
- extended: ExtendedAdvertisingData¶
- class src.bluetooth_sig.types.advertising.AdvertisingDataStructures¶
Bases:
msgspec.StructComplete parsed advertising data structures organized by category.
Contains all AD Types parsed from advertising PDUs (both legacy and extended). These are payload content, not PDU-level metadata.
- core¶
Device identification and services (manufacturer data, UUIDs, name)
- properties¶
Device capabilities (flags, appearance, tx_power, features)
- directed¶
Directed advertising parameters (target addresses, intervals)
- oob_security¶
Out-of-Band security data for pairing
- location¶
Location and sensing data
- mesh¶
Mesh network and broadcast audio data
- security¶
Encrypted advertising and privacy data
- core: CoreAdvertisingData¶
- directed: DirectedAdvertisingData¶
- location: LocationAndSensingData¶
- mesh: MeshAndBroadcastData¶
- oob_security: OOBSecurityData¶
- properties: DeviceProperties¶
- security: SecurityData¶
- class src.bluetooth_sig.types.advertising.BLEAdvertisingFlags¶
Bases:
enum.IntFlagBLE Advertising Flags (Core Spec Supplement, Part A, Section 1.3).
These flags indicate the discoverable mode and capabilities of the advertising device.
- BR_EDR_NOT_SUPPORTED = 4¶
- LE_GENERAL_DISCOVERABLE_MODE = 2¶
- LE_LIMITED_DISCOVERABLE_MODE = 1¶
- RESERVED_BIT_5 = 32¶
- RESERVED_BIT_6 = 64¶
- RESERVED_BIT_7 = 128¶
- SIMULTANEOUS_LE_BR_EDR_CONTROLLER = 8¶
- SIMULTANEOUS_LE_BR_EDR_HOST = 16¶
- class src.bluetooth_sig.types.advertising.BLEAdvertisingPDU¶
Bases:
msgspec.StructBLE Advertising PDU structure.
- extended_header: BLEExtendedHeader | None = None¶
- class src.bluetooth_sig.types.advertising.BLEExtendedHeader¶
Bases:
msgspec.StructExtended Advertising Header fields (BLE 5.0+).
- class src.bluetooth_sig.types.advertising.CoreAdvertisingData¶
Bases:
msgspec.StructCore advertising data - device identification and services.
- manufacturer_data¶
Manufacturer-specific data keyed by company ID
- manufacturer_names¶
Resolved company names keyed by company ID
- service_uuids¶
List of advertised service UUIDs
- service_data¶
Service-specific data keyed by service UUID
- solicited_service_uuids¶
List of service UUIDs the device is seeking
- local_name¶
Device’s local name (complete or shortened)
- uri_data¶
Parsed URI with scheme info from UriSchemesRegistry
- service_data: dict[bluetooth_sig.types.uuid.BluetoothUUID, bytes]¶
- service_uuids: list[bluetooth_sig.types.uuid.BluetoothUUID]¶
- solicited_service_uuids: list[bluetooth_sig.types.uuid.BluetoothUUID]¶
- uri_data: bluetooth_sig.types.uri.URIData | None = None¶
- class src.bluetooth_sig.types.advertising.DeviceProperties¶
Bases:
msgspec.StructDevice capability and appearance properties.
- flags¶
BLE advertising flags (discoverable mode, capabilities)
- appearance¶
Device appearance category and subcategory
- tx_power¶
Transmission power level in dBm
- le_role¶
LE role (peripheral, central, etc.)
- le_supported_features¶
LE supported features bit field
- class_of_device¶
Classic Bluetooth Class of Device value
- class_of_device_info¶
Parsed Class of Device information
- appearance: bluetooth_sig.types.appearance.AppearanceData | None = None¶
- class_of_device: bluetooth_sig.types.registry.class_of_device.ClassOfDeviceInfo | None = None¶
- flags: BLEAdvertisingFlags¶
- class src.bluetooth_sig.types.advertising.DirectedAdvertisingData¶
Bases:
msgspec.StructDirected advertising and timing parameters.
These AD types specify target devices and advertising timing.
- public_target_address¶
List of public target addresses (AD 0x17)
- random_target_address¶
List of random target addresses (AD 0x18)
- le_bluetooth_device_address¶
LE Bluetooth device address (AD 0x1B)
- advertising_interval¶
Advertising interval in 0.625ms units (AD 0x1A)
- advertising_interval_long¶
Long advertising interval (AD 0x2F)
- peripheral_connection_interval_range¶
Preferred connection interval (AD 0x12)
- class src.bluetooth_sig.types.advertising.ExtendedAdvertisingData¶
Bases:
msgspec.StructExtended advertising PDU-level metadata (BLE 5.0+).
This contains PDU-level information specific to extended advertising, NOT AD types (which go in AdvertisingDataStructures).
- extended_payload¶
Raw extended advertising payload bytes
- auxiliary_packets¶
Chained AUX_ADV_IND packets via AuxPtr
- periodic_advertising_data¶
Data from periodic advertising train
- auxiliary_packets: list[BLEAdvertisingPDU]¶
- class src.bluetooth_sig.types.advertising.ExtendedHeaderFlags¶
Bases:
enum.IntEnumExtended advertising header field presence flags (BLE 5.0+).
Each flag indicates whether a corresponding field is present in the extended advertising header.
- ACAD = 128¶
- ADV_ADDR = 1¶
- ADV_DATA_INFO = 8¶
- AUX_PTR = 16¶
- CTE_INFO = 4¶
- SYNC_INFO = 32¶
- TARGET_ADDR = 2¶
- TX_POWER = 64¶
- class src.bluetooth_sig.types.advertising.LocationAndSensingData¶
Bases:
msgspec.StructLocation, positioning, and sensing related data.
- indoor_positioning¶
Indoor positioning data
- three_d_information¶
3D information data
- transport_discovery_data¶
Transport Discovery Data
- channel_map_update_indication¶
Channel Map Update Indication
- class src.bluetooth_sig.types.advertising.MeshAndBroadcastData¶
Bases:
msgspec.StructBluetooth Mesh and audio broadcast related data.
- mesh_message¶
Mesh Message
- mesh_beacon¶
Mesh Beacon
- pb_adv¶
Provisioning Bearer over advertising
- broadcast_name¶
Broadcast name
- broadcast_code¶
Broadcast Code for encrypted audio
- biginfo¶
BIG Info for Broadcast Isochronous Groups
- periodic_advertising_response_timing¶
Periodic Advertising Response Timing Info
- electronic_shelf_label¶
Electronic Shelf Label data
- class src.bluetooth_sig.types.advertising.OOBSecurityData¶
Bases:
msgspec.StructOut-of-Band (OOB) security data advertised for pairing.
These AD types provide security material for OOB pairing mechanisms.
- simple_pairing_hash_c¶
Simple Pairing Hash C-192/C-256 (AD 0x0E, 0x1D)
- simple_pairing_randomizer_r¶
Simple Pairing Randomizer R-192/R-256 (AD 0x0F, 0x1E)
- secure_connections_confirmation¶
LE SC Confirmation Value (AD 0x22)
- secure_connections_random¶
LE SC Random Value (AD 0x23)
- security_manager_tk_value¶
Security Manager TK Value (AD 0x10)
- security_manager_oob_flags¶
SM Out of Band Flags (AD 0x11)
- class src.bluetooth_sig.types.advertising.PDUHeaderFlags¶
Bases:
enum.IntFlagBLE PDU header bit masks for parsing operations.
These masks are pre-positioned to their correct bit locations, eliminating the need for shifts during extraction.
- classmethod extract_bits(header: int, mask: int) int | bool¶
Extract bits from header using the specified mask.
Returns int for multi-bit masks, bool for single-bit masks.
- classmethod extract_pdu_type(header: int) PDUType¶
Extract PDU type from header byte and return as PDUType enum.
- RFU_BIT_4 = 16¶
- RFU_BIT_5 = 32¶
- RX_ADD_MASK = 128¶
- TX_ADD_MASK = 64¶
- TYPE_MASK = 15¶
- class src.bluetooth_sig.types.advertising.PDULayout¶
BLE PDU structure size and offset constants.
Defines the sizes and offsets of fields within BLE PDU structures following Bluetooth Core Spec Vol 6, Part B.
- class src.bluetooth_sig.types.advertising.PDUType¶
Bases:
enum.IntEnumBLE Advertising PDU Types (Core Spec Vol 6, Part B, Section 2.3).
- ADV_AUX_IND = 8¶
- ADV_DIRECT_IND = 1¶
- ADV_EXT_IND = 7¶
- ADV_IND = 0¶
- ADV_NONCONN_IND = 2¶
- ADV_SCAN_IND = 6¶
- CONNECT_IND = 5¶
- SCAN_REQ = 3¶
- SCAN_RSP = 4¶