able.BluetoothDispatcher
able.BluetoothDispatcher#
- class able.BluetoothDispatcher(queue_timeout: float = 0.5, enable_ble_code: int = 43806, runtime_permissions: Optional[list[str]] = None)[source]#
Bluetooth Low Energy interface
- Parameters
queue_timeout – BLE operations queue timeout
enable_ble_code – request code to identify activity that alows user to turn on Bluetooth adapter
runtime_permissions – overridden list of
permissions
to be requested on runtime.
- __init__(queue_timeout: float = 0.5, enable_ble_code: int = 43806, runtime_permissions: Optional[list[str]] = None)#
Methods
__init__
([queue_timeout, enable_ble_code, ...])apply_property
(self, **kwargs)Adds properties at runtime to the class.
bind
(self, **kwargs)Bind an event type or a property to a callback.
Close current GATT client
connect_by_device_address
(address)Connect to GATT Server of the device with a given Bluetooth hardware address, without scanning.
connect_gatt
(device)Connect to GATT Server hosted by device
create_property
(self, unicode name[, value, ...])Create a new property at runtime.
Discovers services offered by a remote device.
dispatch
(self, event_type, *largs, **kwargs)Dispatch an event across all the handlers added in bind/fbind().
dispatch_children
(self, event_type, *largs, ...)dispatch_generic
(self, event_type, *largs, ...)enable_notifications
(characteristic[, ...])Enable/disable notifications or indications for a given characteristic
events
(self)Return all the events in the class.
fbind
(self, name, func, *largs, **kwargs)A method for advanced, and typically faster binding.
funbind
(self, name, func, *largs, **kwargs)Similar to
fbind()
.get_property_observers
(self, name[, args])Returns a list of methods that are bound to the property/event passed as the name argument.
getter
(self, name)Return the getter of a property.
is_event_type
(self, event_type)Return True if the event_type is already registered.
on_bluetooth_adapter_state_change
(state)bluetooth_adapter_state_change event handler
on_characteristic_changed
(characteristic)characteristic_changed event handler
on_characteristic_read
(characteristic, status)characteristic_read event handler
on_characteristic_write
(characteristic, status)characteristic_write event handler
on_connection_state_change
(status, state)connection_state_change event handler
on_descriptor_read
(descriptor, status)descriptor_read event handler
on_descriptor_write
(descriptor, status)descriptor_write event handler
on_device
(device, rssi, advertisement)device event handler.
on_error
(msg)Error handler
gatt_release event handler.
on_mtu_changed
(mtu, status)onMtuChanged event handler Event is dispatched when MTU for a remote device has changed, reporting a new MTU size.
on_rssi_updated
(rssi, status)onReadRemoteRssi event handler.
scan_completed event handler
on_scan_started
(success)scan_started event handler
on_services
(services, status)services event handler
properties
(self)Return all the properties in the class in a dictionary of key/property class.
property
(self, name[, quiet])Get a property instance from the property name.
read_characteristic
(characteristic)Read a given characteristic from the associated remote device
register_event_type
(self, event_type)Register an event type with the dispatcher.
request_mtu
(mtu)Request to change the ATT Maximum Transmission Unit value
set_queue_timeout
(timeout)Change the BLE operations queue timeout
setter
(self, name)Return the setter of a property.
start_scan
([filters, settings])Start a scan for devices.
Stop the ongoing scan for devices.
unbind
(self, **kwargs)Unbind properties from callback functions with similar usage as
bind()
.unbind_uid
(self, name, uid)Uses the uid returned by
fbind()
to unbind the callback.unregister_event_type
(self, event_type)Unregister an event type in the dispatcher.
unregister_event_types
(self, event_type)Triggers an update for the RSSI from the associated remote device
write_characteristic
(characteristic, value)Write a given characteristic value to the associated remote device
write_descriptor
(descriptor, value)Set and write the value of a given descriptor to the associated remote device
Attributes
Local device Bluetooth adapter.
List of Java android.bluetooth.BluetoothDevice objects of paired BLE devices.
GATT profile of the connected device
Name of the Bluetooth adapter.
proxy_ref
Returns a
WeakProxy
reference to theEventDispatcher
.uid