src.bluetooth_sig.types.uuid

Bluetooth UUID utilities for handling 16-bit and 128-bit UUIDs.

Classes

Name

Description

BluetoothUUID

Bluetooth UUID class that handles both 16-bit and 128-bit UUIDs with automatic normalization and conversion.

Module Contents

class src.bluetooth_sig.types.uuid.BluetoothUUID(uuid: str | int | BluetoothUUID)

Bluetooth UUID class that handles both 16-bit and 128-bit UUIDs with automatic normalization and conversion.

Supports various input formats: - Short form: “180F”, “0x180F”, “180f” - Full form: “0000180F-0000-1000-8000-00805F9B34FB” - Normalized: “0000180F00001000800000805F9B34FB” - Integer: 6159 (for 16-bit) or large integer (for 128-bit)

Provides automatic conversion between formats and consistent comparison.

is_sig_characteristic() bool

Check if this UUID is a Bluetooth SIG assigned characteristic UUID.

Based on actual SIG assigned numbers from characteristic_uuids.yaml. Range verified: 0x2A00 to 0x2C24 (and potentially expanding).

Returns:

True if this is a SIG characteristic UUID, False otherwise

is_sig_service() bool

Check if this UUID is a Bluetooth SIG assigned service UUID.

Based on actual SIG assigned numbers from service_uuids.yaml. Range verified: 0x1800 to 0x185C (and potentially expanding).

Returns:

True if this is a SIG service UUID, False otherwise

is_valid_for_custom_characteristic() bool

Check if this UUID is valid for custom characteristics.

Returns:

  • Base UUID (00000000-0000-1000-8000-00805f9b34fb)

  • Null UUID (all zeros)

  • Placeholder UUID (used internally)

True otherwise

Return type:

False if the UUID is any of the invalid/reserved UUIDs

matches(other: str | BluetoothUUID) bool

Check if this UUID matches another UUID (handles format conversion automatically).

BASE_UUID = '0000XXXX00001000800000805F9B34FB'
INVALID_BASE_UUID_DASHED = '00000000-0000-1000-8000-00805f9b34fb'
INVALID_BASE_UUID_NORMALIZED = '0000000000001000800000805F9B34FB'
INVALID_NULL_UUID = '0000000000000000000000000000'
INVALID_PLACEHOLDER_UUID = '0000123400001000800000805F9B34FB'
INVALID_SHORT_UUID = '0000'
SIG_BASE_SUFFIX = '00001000800000805F9B34FB'
SIG_CHARACTERISTIC_MAX = 11300
SIG_CHARACTERISTIC_MIN = 10752
SIG_SERVICE_MAX = 6236
SIG_SERVICE_MIN = 6144
UUID_FULL_LEN = 32
UUID_SHORT_LEN = 4
property bytes: bytes

Get UUID as 16-byte binary representation (big-endian).

Useful for BLE wire protocol operations where UUIDs need to be transmitted in binary format.

Returns:

16 bytes representing the full 128-bit UUID in big-endian byte order

property bytes_le: bytes

Get UUID as 16-byte binary representation (little-endian).

Some BLE operations require little-endian byte order.

Returns:

16 bytes representing the full 128-bit UUID in little-endian byte order

property dashed_form: str

Get UUID in standard dashed format (e.g., ‘0000180F-0000-1000-8000-00805F9B34FB’).

property full_form: str

Get 128-bit full form with Bluetooth base UUID.

property int_value: int

Get UUID as integer value.

property is_full: bool

Check if this is a 128-bit (full) UUID.

property is_short: bool

Check if this is a 16-bit (short) UUID.

property normalized: str

Get normalized UUID (uppercase hex, no dashes, no 0x prefix).

property short_form: str

Get 16-bit short form (e.g., ‘180F’).