pamoja.lorawan.clock
Application layer clock synchronization, TS003-2.0.0, on port PORT.
A device that has no clock of its own still needs the time: a multicast window and a scheduled reboot both depend on it. The device says what time it believes it is, the server answers with the difference, and a four-bit token keeps a late answer from pulling a corrected clock back.
>>> from pamoja.lorawan import clock, package_encode, package_parse
>>> sync = clock.ClockSync()
>>> asked = package_parse(clock.PORT, True, sync.request(1_000_000))
>>> answer = package_encode(
... clock.PORT, "app_time_ans", time_correction=12, token=asked.token
... )
>>> sync.heard(answer).correction
12
1"""Application layer clock synchronization, TS003-2.0.0, on port :data:`PORT`. 2 3A device that has no clock of its own still needs the time: a multicast window and a scheduled 4reboot both depend on it. The device says what time it believes it is, the server answers with 5the difference, and a four-bit token keeps a late answer from pulling a corrected clock back. 6 7>>> from pamoja.lorawan import clock, package_encode, package_parse 8>>> sync = clock.ClockSync() 9>>> asked = package_parse(clock.PORT, True, sync.request(1_000_000)) 10>>> answer = package_encode( 11... clock.PORT, "app_time_ans", time_correction=12, token=asked.token 12... ) 13>>> sync.heard(answer).correction 1412 15""" 16 17from __future__ import annotations 18 19from pamoja._native import LORAWAN_CLOCK_PORT, LorawanClockHeard, LorawanClockSync 20 21__all__ = ["PORT", "ClockHeard", "ClockSync"] 22 23#: The port this package is spoken on. 24PORT = LORAWAN_CLOCK_PORT 25 26#: What a device made of a downlink on the clock port. 27ClockHeard = LorawanClockHeard 28 29#: The clock synchronization package running on a device. 30ClockSync = LorawanClockSync
PORT =
202
ClockHeard =
<class 'builtins.LorawanClockHeard'>
ClockSync =
<class 'builtins.LorawanClockSync'>