-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Various improvements to NtpClient class #1482
Various improvements to NtpClient class #1482
Conversation
* Fix #include guard name * Tidy #includes * Put NTP_DEFAULT_SERVER into Flash * Use const String& for parameters * Use SimpleTimer instead of Timer as appropriate (efficiency, saves RAM) * timeoutTimer doesn't need to be initialised until a request has been queued, so moved out of constructor * Replace staticDnsResponse() with lambda * Tidy extraction of timestamp from received packet using LWIP macro
* Rewrite using one timer * Set timer to retry on initial request, and only stop it on success or cancellation * Add retry if bad NTP packet received * Change int arguments to unsigned
I've emulated the synchronization problem of #1449 by giving
Patch for the above test using
|
// init timer but do not start, correct interval set later below. | ||
autoUpdateTimer.initializeMs(NTP_DEFAULT_QUERY_INTERVAL_SECONDS * 1000, | ||
TimerDelegate(&NtpClient::requestTime, this)); | ||
debug_d("NtpClient(\"%s\", %u, 0x%08x", reqServer.c_str(), reqIntervalSeconds, delegateFunction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikee47 We have a problem here. Either remove the delegateFunction parameter or replace it something like delegateFunction ? 1:0
. Or cast it to an address, if that was the initial intention.
In order to reproduce the problem compile Sming with DEBUG_VERBOSE_LEVEL=3
.
cd %SMING_HOME%
make dist-clean
make DEBUG_VERBOSE_LEVEL=3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was silly of me! I've removed the parameter, doesn't really help anyway.
Tested with SystemClock_NTP sample, but note that time will be wrong as we don't yet have any timezone management in place. The sample also sets local time, but NTP provides time in UTC. No point in fixing that yet as without timezone it just makes things worse.
Closes: #1449