Skip to content

add configurable time between NTP calls#37

Merged
tannewt merged 5 commits into
adafruit:mainfrom
tedder:ted/configurable_cache_time_2
Jul 18, 2024
Merged

add configurable time between NTP calls#37
tannewt merged 5 commits into
adafruit:mainfrom
tedder:ted/configurable_cache_time_2

Conversation

@tedder
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread adafruit_ntp.py
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread adafruit_ntp.py Outdated
Copy link
Copy Markdown
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
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jul 23, 2024
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