blatann.services.battery.service module¶
- class blatann.services.battery.service.BatteryServer(service, enable_notifications=False, security_level=SecurityLevel.OPEN)¶
Bases:
object
- set_battery_level(battery_percent, notify_client=True)¶
Sets the new battery level in the service
- Parameters
battery_percent (
int
) – The new battery percentnotify_client – Whether or not to notify the connected client with the updated value
- classmethod add_to_database(gatts_database, enable_notifications=False, security_level=SecurityLevel.OPEN)¶
- class blatann.services.battery.service.BatteryClient(gattc_service)¶
Bases:
object
- read()¶
Reads the Battery level characteristic.
- Return type
EventWaitable
[BatteryClient
,DecodedReadCompleteEventArgs
[int
]]- Returns
A waitable for when the read completes, which waits for the on_battery_level_update_event to be emitted
- property on_battery_level_updated: Event[BatteryClient, DecodedReadCompleteEventArgs[int]]¶
Event that is generated whenever the battery level on the peripheral is updated, whether it is by notification or from reading the characteristic itself.
The DecodedReadCompleteEventArgs value given is the integer battery percent received. If the read failed or failed to decode, the value will be equal to the raw bytes received.
- property can_enable_notifications: bool¶
Checks if the battery level characteristic allows notifications to be subscribed to
- Returns
True if notifications can be enabled, False if not
- enable_notifications()¶
Enables notifications for the battery level characteristic. Note: this function will raise an exception if notifications aren’t possible
- Returns
a Waitable which waits for the write to finish
- disable_notifications()¶
Disables notifications for the battery level characteristic. Note: this function will raise an exception if notifications aren’t possible
- Returns
a Waitable which waits for the write to finish
- classmethod find_in_database(gattc_database)¶
- Return type