add example pico_w/wifi/ntp_system_time
A proposed new NTP example that differs from the existing pico_w/wifi/ntp_client in the following ways:
- uses the SNTP app already provided by lwIP (in threadsafe background mode)
- uses
pico_aon_timerto create a time-of-day clock that can be read asynchronously from user code - illustrates the use of a POSIX timezone (TZ) to convert UTC to local time with daylight saving
- includes a README.md to explain what the example does and how to use it
The program connects to Wi-Fi, initialises the lwIP SNTP app, syncs the pico_aon_timer to NTP and then enters a loop to display the local time in London (or UTC, or whichever timezone the user defines); resynchronising to ntp.pool.org in the background every hour.
I suggest it's quite an important use case for the Pico-W, and illustrates a couple of features users may find helpful (such as how to create and use a POSIX timezone).
Hmmm, if #716 and #714 got together and had a baby... :thinking: :joy:
Hmmm, if #716 and #714 got together and had a baby... 🤔 😂
https://digitalcollections.smu.edu/digital/collection/tir/id/205/
Thanks for the extra comments :+1:
Not having done any time-based processing in C myself, I was misreading asctime() as ascii_time() whereas I guess it's actually meant to be read as as_ctime() :joy:
I was misreading
asctime()asascii_time()whereas I guess it's actually meant to be read asas_ctime()😂
Oooo never considered that... My "lengthy and extensive research" (ha ha) suggests it might be the former: https://retrocomputing.stackexchange.com/questions/25601/what-is-the-meaning-of-asctime
In fact for anything more complex than a timestamp it's probably better to use strftime() but that's a bit OTT for an embedded app :-)
Found a way to avoid hardcoding the timezone names in the printf() :-)
Many thanks for the excellent suggestions - should be all wrapped up in the latest commit (please let me know if I missed anything)
Looking really good now - many thanks again for your time to review
Spent far too long today chasing down why some simple test code couldn't find the function definition for setenv(). Eventually realised it was because in the example I'd forgotten to #include <stdlib.h>, and got away with it because lwIP pulls it in.
Hopefully by importing it explicitly it'll save someone else from the same fate...