src.bluetooth_sig.types.uri¶
URI data types for Bluetooth advertising.
Classes¶
Name | Description |
|---|---|
Parsed URI from Bluetooth advertising data. |
Module Contents¶
- class src.bluetooth_sig.types.uri.URIData¶
Bases:
msgspec.StructParsed URI from Bluetooth advertising data.
The Bluetooth SIG URI AD type (0x24) uses a compressed format where the first byte is a scheme code from the URI Schemes registry, followed by the remainder of the URI encoded as UTF-8.
- For example:
0x16 = “http:” prefix
0x17 = “https:” prefix
- scheme_code¶
Raw scheme code from first byte (0 if plain URI)
- scheme_info¶
Resolved scheme information from registry
- full_uri¶
Complete decoded URI with scheme prefix
- raw_data¶
Original raw bytes from advertising data
- classmethod from_plain_uri(uri: str) URIData¶
Create URIData from a plain URI string (no scheme encoding).
Use this for URIs that aren’t using Bluetooth SIG compressed encoding.
- Parameters:
uri – Plain URI string
- Returns:
URIData with the URI stored directly
- classmethod from_raw_data(data: bytes) URIData¶
Parse URI advertising data using Bluetooth SIG encoding.
The first byte is a URI scheme code from the registry. The remaining bytes are the URI suffix encoded as UTF-8.
- Parameters:
data – Raw bytes from URI AD type (ADType 0x24)
- Returns:
URIData with decoded URI and scheme information
Example
>>> # 0x17 = "https:", followed by "//example.com" >>> uri_data = URIData.from_raw_data(b"\x17//example.com") >>> uri_data.full_uri 'https://example.com' >>> uri_data.scheme_name 'https:'
- property is_known_scheme: bool¶
Check if the URI scheme is a known Bluetooth SIG registered scheme.
- Returns:
True if scheme_code resolved to a known scheme.