@@ -165,17 +165,23 @@ class NTP: # pylint:disable=too-many-instance-attributes
165
165
166
166
This class uses a simple state machine to manage synchronization:
167
167
- USING_CACHED_REFERENCE (state 3): The default state where the cached time reference is used.
168
- - Transitions to GETTING_SOCKET when the cache expires.
168
+
169
+ - Transitions to GETTING_SOCKET when the cache expires.
170
+
169
171
- GETTING_SOCKET (state 1): Attempts to perform a DNS lookup for the NTP server.
170
- - Transitions to GETTING_PACKET on success.
171
- - Remains in this state if retries are needed.
172
+
173
+ - Transitions to GETTING_PACKET on success.
174
+ - Remains in this state if retries are needed.
175
+
172
176
- GETTING_PACKET (state 2): Sends an NTP request and waits for the response.
173
- - Transitions back to USING_CACHED_REFERENCE.
174
- - On failure, any existing cached value will continue to be used until the next scheduled
175
- synchronization.
176
177
177
- The state transitions are managed by the `_update_time_sync` method, which is called if
178
- the cached time is expired when `utc_ns` is accessed.
178
+ - Transitions back to USING_CACHED_REFERENCE.
179
+
180
+ - On failure, any existing cached value will continue to be used until the next scheduled
181
+ synchronization.
182
+
183
+ The state transitions are managed by the ``_update_time_sync`` method, which is called if
184
+ the cached time is expired when ``utc_ns`` is accessed.
179
185
"""
180
186
181
187
# State machine values
@@ -374,15 +380,15 @@ def register_ntp_event_callback(
374
380
375
381
Callbacks can be used to turn off the radio to save power, initiate a network
376
382
connection, or other progress monitoring processes.
377
- EG: `wifi.radio.enabled = False` or `connection_manager.connect()`
383
+ EG: `` wifi.radio.enabled = False`` or `` connection_manager.connect()` `
378
384
379
385
.. caution::
380
386
381
387
This implementation does not prevent duplicate registration of the same callback.
382
388
All attempts to consistently identify when a callback is already registered have
383
389
failed due to the limitations of the current CircuitPython implementation. Comparing
384
- the callback value directly, converting to string using `str()`, or `repr()`, or to a
385
- number using `id()` all have cases where an identical callback reference will be
390
+ the callback value directly, converting to string using `` str()`` , or `` repr()` `, or to a
391
+ number using `` id()` ` all have cases where an identical callback reference will be
386
392
treated as different.
387
393
388
394
If the same callback is registered multiple times, with the same event type, it will
@@ -391,8 +397,8 @@ def register_ntp_event_callback(
391
397
:param Callable[[IntFlag, int], None] callback: The callback function to register.
392
398
:param IntFlag event_types: The event types that should trigger this callback. This can
393
399
be a single event type or a combination of multiple events.
394
- Defaults to `EventType.SYNC_COMPLETE`.
395
- :raises TypeError: If the `event_types` argument is not a valid event type or combination
400
+ Defaults to `` EventType.SYNC_COMPLETE` `.
401
+ :raises TypeError: If the `` event_types` ` argument is not a valid event type or combination
396
402
of event types.
397
403
398
404
Usage examples::
0 commit comments