BlueZ DBus (Linux)
The BlueZ DBus backend implements GATT services and advertising using BlueZ DBus APIs.
- class bless.backends.bluezdbus.characteristic.BlessGATTCharacteristicBlueZDBus(*args: Any, **kwargs: Any)
BlueZ implementation of the BlessGATTCharacteristic
- property description: str
Description of this characteristic
- property handle: int
The handle of this characteristic
- async init(service: BlessGATTService)
Initialize the BlueZGattCharacteristic object
- Parameters:
service (BlessGATTService) – The service to assign the characteristic to
- property service_handle: int
The handle of the service this characteristic belongs to
- property service_uuid: str
The UUID of the service this characteristic belongs to
- property subscribed_centrals: Set[str]
Unique list of subscribed central IDs
- property uuid: str
The uuid of this characteristic
- property value: bytearray
Get the value of the characteristic
- bless.backends.bluezdbus.characteristic.flags_to_dbus(flags: GATTCharacteristicProperties) List[Flags]
Convert Bleak/Bless flags
- Parameters:
flags (GATTCharacteristicProperties) – The numerical enumeration for the combined flags
- Returns:
A list fo Flags for use in BlueZDBus
- Return type:
List[Flags]
- bless.backends.bluezdbus.characteristic.transform_flags_with_permissions(flag: Flags, permissions: GATTAttributePermissions) Flags
Returns the encrypted variant of a flag if the corresponding permission is set.
- class bless.backends.bluezdbus.descriptor.BlessGATTDescriptorBlueZDBus(*args: Any, **kwargs: Any)
BlueZ implementation of the BlessGATTDescriptor
- async init(characteristic: BlessGATTCharacteristic)
Initialize the BlueZGattDescriptor object
- Parameters:
characteristic (BlessGATTCharacteristic) – The characteristic to assign the descriptor to
- property uuid: str
The uuid of this characteristic
- property value: bytearray
Get the value of the characteristic
- bless.backends.bluezdbus.descriptor.flags_to_dbus(flags: GATTDescriptorProperties) List[DescriptorFlags]
Convert Bleak/Bless flags
- Parameters:
flags (GATTDescriptorProperties) – The numerical enumeration for the combined flags
- Returns:
A list fo Flags for use in BlueZDBus
- Return type:
List[DescriptorFlags]
- bless.backends.bluezdbus.descriptor.transform_flags_with_permissions(flag: DescriptorFlags, permissions: GATTAttributePermissions) DescriptorFlags
Returns the encrypted variant of a flag if the corresponding permission is set.
- Parameters:
flag (GATTDescriptorProperties) – The numerical enumeration of a single flag
permissions (GATTAttributePermissions) – The permissions for the characteristic
- Returns:
A Flags enum value for use in BlueZDBus that reflects encryption requirements.
- Return type:
List[DescriptorFlags]
- class bless.backends.bluezdbus.dbus.application.BlueZGattApplication(*args: Any, **kwargs: Any)
org.bluez.GattApplication1 interface implementation
- async add_characteristic(service_uuid: str, uuid: str, value: Any, flags: List[Flags]) BlueZGattCharacteristic
Add a characteristic to the service
- Parameters:
service_uuid (str) – The string representation of the UUID for the service that this characteristic belongs to
uuid (str) – The string representation of the UUID for the characteristic
value (Any) – The value of the characteristic,
flags (List[Flags]) – A list of flags to apply to the characteristic
- Returns:
The characteristic object
- Return type:
BlueZGattCharacteristic
- async add_service(uuid: str, primary: bool | None = None) BlueZGattService
Add a service to the application The first service to be added will be the primary service
- Parameters:
uuid (str) – The string representation of the uuid for the service to create
primary (Optional[bool]) – True if this is a primary service, False otherwise. If None, the first service added will be primary, all others will be secondary
- Returns:
Returns and instance of the service object
- Return type:
BlueZGattService
- async is_advertising(adapter: dbus_next.aio.ProxyObject) bool
Check if the adapter is advertising
- Parameters:
adapter (ProxyObject) – The adapter object to check for advertising
- Returns:
Whether the adapter is advertising anything
- Return type:
bool
- async is_connected() bool
Check if the application is connected This is not the same as if the adapter is connected to a device, but rather if there is a subscribed characteristic
- Returns:
Whether a central device is subscribed to one of our characteristics
- Return type:
bool
- async register(adapter: dbus_next.aio.ProxyObject)
Register the application with BlueZDBus
- Parameters:
adapter (ProxyObject) – The adapter to register the application with
- async set_name(adapter: dbus_next.aio.ProxyObject, name: str)
Set’s the alias of our bluetooth adapter to our application’s name
- Parameters:
adapter (ProxyObject) – The adapter whose alias name to set
name (str) – The namem to set the adapter alias
- async start_advertising(adapter: dbus_next.aio.ProxyObject, advertisement_data: BlessAdvertisementData | None = None)
Start Advertising the application
- Parameters:
adapter (ProxyObject) – The adapter object to start advertising on
advertisement_data (Optional[BlessAdvertisementData]) – Optional advertisement payload to populate BlueZ advertisement data
- async stop_advertising(adapter: dbus_next.aio.ProxyObject)
Stop Advertising
- Parameters:
adapter (ProxyObject) – The adapter object to stop advertising
- async unregister(adapter: dbus_next.aio.ProxyObject)
Unregister the application with BlueZDBus
- Parameters:
adapter (ProxyObject) – The adapter on which the current application is registered
- class bless.backends.bluezdbus.dbus.advertisement.BlueZLEAdvertisement(*args: Any, **kwargs: Any)
org.bluez.LEAdvertisement1 interface implementation
https://github.com/bluez/bluez/blob/5.64/doc/advertising-api.txt https://python-dbus-next.readthedocs.io/en/latest/type-system/index.html https://elixir.bootlin.com/linux/v5.11/source/include/net/bluetooth/mgmt.h#L794 https://github.com/bluez/bluez/issues/527 https://patches.linaro.org/project/linux-bluetooth/list/?series=31700
- class bless.backends.bluezdbus.dbus.advertisement.Type(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)