Extension to lwip sntp to provide a weak callback notifying us the ti… (IDFGH-991) #1668
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.