bluez_peripheral.util module
- class bluez_peripheral.util.Adapter(proxy: ProxyObject)
Bases:
objectA bluetooth adapter.
- async get_address() str
Read the bluetooth address of this device.
- async get_alias() str
The user friendly name of the device.
- async classmethod get_all(bus: MessageBus) Collection[Adapter]
Get a list of available Bluetooth adapters.
- Parameters
bus (MessageBus) – The message bus used to query bluez.
- Returns
A list of available bluetooth adapters.
- Return type
Collection[Adapter]
- async classmethod get_first(bus: MessageBus) Adapter
Gets the first adapter listed by bluez.
- Parameters
bus (MessageBus) – The bus to use for adapter discovery.
- Raises
ValueError – Raised when no bluetooth adapters are available.
- Returns
The resulting adapter.
- Return type
- async get_name() str
Read the bluetooth hostname of this system.
- async get_powered() bool
Indicates if the adapter is on or off.
- async set_alias(val: str)
Set the user friendly name for this device. Changing the device hostname directly is preferred. Writing an empty string will result in the alias resetting to the device hostname.
- async set_powered(val: bool)
Turn this adapter on or off.
- async bluez_peripheral.util.get_message_bus() MessageBus
Gets a system message bus to use for registering services and adverts.
- async bluez_peripheral.util.is_bluez_available(bus: MessageBus) bool
Checks if bluez is registered on the system dbus.
- Parameters
bus (MessageBus) – The system dbus to use.
- Returns
True if bluez is found. False otherwise.
- Return type
bool