blatann.services.current_time.service module

class blatann.services.current_time.service.CurrentTimeServer(service, is_writable=False, enable_local_time_info_char=False, enable_ref_time_info_char=False)

Bases: object

property is_writable: bool

Gets whether or not the service was configured to allow writes to the Current Time and Local Time Info characteristics

property has_local_time_info: bool

Gets whether or not the service was configured to show the Local Time Info characteristic

property has_reference_time_info: bool

Gets whether or not the service was configured to show the Reference Time Info characteristic

property on_current_time_write: Event[CurrentTimeServer, DecodedWriteEventArgs[CurrentTime]]

Event that is triggered when a client writes to the Current Time Characteristic. Event emits a DecodedWriteEventArgs argument where the value is of type current_time.CurrentTime

property on_local_time_info_write: Event[CurrentTimeServer, DecodedWriteEventArgs[LocalTimeInfo]]

Event that is triggered when a client writes to the Local Time Info Characteristic (if present). Event emits a DecodedWriteEventArgs argument where the value is of type current_time.LocalTimeInfo

configure_automatic()

Configures the current time and local time info (if present) to use the system time

set_time(date=None, adjustment_reason=None, characteristic_read_callback=None)

Manually sets the time to report to the client.

If characteristic_read_callback is supplied, the function is called for future reads on that characteristic to fetch the current time If characteristic_read_callback is None, future reads will be based off of the base datetime given and the time passed

Parameters
  • date (datetime.datetime) – The new base date to set the characteristic to. Future characteristic reads will base its time off of this value if characteristic_read_callback is not supplied. If the date is not supplied, will use the current system time (same as configure_automatic but doesn’t configure local time info)

  • adjustment_reason (AdjustmentReason) – Optional reason to give for the adjustment

  • characteristic_read_callback – Optional callback to fetch subsequent time values. Function signature should take no parameters and return a datetime object

set_local_time_info(timezone_hrs=0.0, dst_offset=DaylightSavingsTimeOffset.standard_time)

Sets the local time info characteristic data. Only valid if has_local_time_info is True

Parameters
  • timezone_hrs – The timezone to report, in hours

  • dst_offset (DaylightSavingsTimeOffset) – The daylight savings time offset

Raises

InvalidOperationException if the service was not configured with the local time info

set_reference_info(time_source=TimeSource.unknown, accuracy=TimeAccuracy.unknown, hours_since_update=None)

Sets the time reference info characteristic data. Only valid if has_reference_time_info is True

Parameters
  • time_source (TimeSource) – The time source to use

  • accuracy (TimeAccuracy) – The accuracy to report

  • hours_since_update – The number of hours since time reference has been updated

Raises

InvalidOperationException if the service was not configured with the reference info

classmethod add_to_database(gatts_database, is_writable=False, enable_local_time_info_char=False, enable_ref_time_info_char=False)
class blatann.services.current_time.service.CurrentTimeClient(gattc_service)

Bases: object

property on_current_time_updated: Event[CurrentTimeClient, DecodedReadCompleteEventArgs[CurrentTime]]

Event triggered when the server has updated its current time

property on_local_time_info_updated: Event[CurrentTimeClient, DecodedReadCompleteEventArgs[LocalTimeInfo]]

Event triggered when the server has updated its local time info

property on_reference_info_updated: Event[CurrentTimeClient, DecodedReadCompleteEventArgs[ReferenceTimeInfo]]

Event triggered when the server has updated its reference time info

property has_local_time_info: bool
property has_reference_info: bool
property can_enable_notifications: bool
property can_set_current_time: bool
property can_set_local_time_info: bool
read_time()

Reads the time from the server

Return type

EventWaitable[CurrentTimeClient, DecodedReadCompleteEventArgs[CurrentTime]]

set_time(date, adjustment_reason=None)

Sets the time on the server to the datetime provided