Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Extension to lwip sntp to provide a weak callback notifying us the ti… #1668
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 , using weak linked overridable functions.
User code can then override
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.
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.
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.
referenced this pull request
Sep 4, 2018
What about a callback in esp/settimeofday function, that way, it does not depends on LWIP version at all ?