Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add configurable time between NTP calls #37

Merged
merged 5 commits into from
Jul 18, 2024

Conversation

tedder
Copy link
Contributor

@tedder tedder commented Jul 16, 2024

Currently, calls to ntp are made 2**poll seconds apart. Since 0.adafruit.pool.ntp.org returns poll=3, the calls can be made every 8 seconds. Adding a way to set the request interval and defaulting to an hour, which seems like a reasonable value for a microcontroller.

@tedder tedder mentioned this pull request Jul 16, 2024
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the enhancement! Two suggestions and then it should be ready.

@@ -55,6 +56,8 @@ def __init__(
CircuitPython. CPython will determine timezone automatically and adjust (so don't use
this.) For example, Pacific daylight savings time is -7.
:param int socket_timeout: UDP socket timeout, in seconds.
:param int cache_seconds: how many seconds to use a cached result from NTP server
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that's a good default but I'd rather not change behavior. Instead, I'd default to None to indicate following the server.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll default it to zero- min(int, None) is an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, pushed the 'zero', and then changed all of the examples to use the 3600 value, since most people just copy/paste example code anyhow. Did it in a standalone commit in case you disagree and want me to revert.

adafruit_ntp.py Outdated Show resolved Hide resolved
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you!

@tannewt tannewt merged commit 18c60dc into adafruit:main Jul 18, 2024
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jul 23, 2024
Updating https://github.com/adafruit/Adafruit_CircuitPython_24LC32 to 1.1.1 from 1.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_24LC32#24 from Timeline8/doc_fix_line_226

Updating https://github.com/adafruit/Adafruit_CircuitPython_NTP to 3.2.0 from 3.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_NTP#37 from tedder/ted/configurable_cache_time_2

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants