src.bluetooth_sig.gatt.characteristics.custom¶
Custom characteristic base class with auto-registration support.
Classes¶
Name | Description |
|---|---|
Helper base class for custom characteristic implementations. |
Module Contents¶
- class src.bluetooth_sig.gatt.characteristics.custom.CustomBaseCharacteristic(info: src.bluetooth_sig.types.CharacteristicInfo | None = None, auto_register: bool = True, validation: src.bluetooth_sig.gatt.characteristics.base.ValidationConfig | None = None)¶
Bases:
src.bluetooth_sig.gatt.characteristics.base.BaseCharacteristic[Any]Helper base class for custom characteristic implementations.
This class provides a wrapper around physical BLE characteristics that are not defined in the Bluetooth SIG specification. It supports both manual info passing and automatic class-level _info binding via __init_subclass__.
- Auto-Registration:
Custom characteristics automatically register themselves with the global BluetoothSIGTranslator singleton when first instantiated. No manual registration needed!
Examples
>>> from bluetooth_sig.types.data_types import CharacteristicInfo >>> from bluetooth_sig.types.uuid import BluetoothUUID >>> class MyCharacteristic(CustomBaseCharacteristic): ... _info = CharacteristicInfo(uuid=BluetoothUUID("AAAA"), name="My Char") >>> # Auto-registers with singleton on first instantiation >>> char = MyCharacteristic() # Auto-registered! >>> # Now accessible via the global translator >>> from bluetooth_sig import BluetoothSIGTranslator >>> translator = BluetoothSIGTranslator.get_instance() >>> result = translator.parse_characteristic("AAAA", b"\x42")