-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Extension to lwip sntp to provide a weak callback notifying us the ti… (IDFGH-991) #1668
Conversation
…me has been set by sntp
Hi @markwj, at the moment we are working on a similar feature that allows installing custom callback for the SNTP update function, at run time. |
Runtime registration of custom callback would also be fine. That was my original approach, but @projectgus suggested weak linking may be more appropriate. Both work just fine for me. So long as I can (a) get notified when the time is set, and (b) be allowed to set the time myself. |
Ok, sorry for the extra work you had to do @markwj. The change to LwIP SNTP module which allows runtime registration of an update hook (and also smooth time adjustment via adjtime) is in review at the moment. |
I'm glad to see, I'm not the only one needing this feature. I was thinking of implementing something similar myself. @igrr could you provide a link to the runtime registration review/pull request? |
@mwick83 that would be on our internal code review system, sorry. |
@igrr Oh, I see. Do you have an ETA when we can expect to see it on master? |
Hi @mwick83 , Sorry noone got back to you for so long. The change to add a runtime hook to LWIP SNTP has been held back behind a major update of LWIP to a newer upstream version. Once that merges then we plan to apply the patch to add this hook (which we then plan to send upstream as well). Because the LWIP update is fairly major it's taken longer than expected to review and update. Sorry for the long delay. Angus |
What about a callback in esp/settimeofday function, that way, it does not depends on LWIP version at all ?
|
Any news here? |
nice! 7e5be1b |
Regarding:
https://www.esp32.com/viewtopic.php?f=13&t=4833
and
https://www.esp32.com/viewtopic.php?f=2&t=4695
A few users (vonnieda, loboris, and myself) have asked for a way of overriding, or getting notified of, the SNTP time being set. The use case here is to be able to delay the main application code until we have an accurate clock. The application flow then becomes:
1] Wait for network to come up
2] Wait for SNTP time to be set
Following forum discussions with ESP_Sprite, and ESP_Angus, this patch implements a mechanism for [2], using weak linked overridable functions.
User code can then override
void sntp_setsystemtime_us(u32_t t, u32_t us)
to be notified of, and set, system time.
For compatibility and completeness, we have also provided a void sntp_setsystemtime(u32_t t), although this does not seem to be required for the standard ESP32 environment.