Page 1 of 1

Which SNTP Server was used to synchronize IDF 5.1 and newer

Posted: Mon Jan 15, 2024 12:48 pm
by chruge
Dear all

I used SNTP to synchronize time.

In my application I allow three time servers. Initially the project was created in ESP-IDF 4.4. There I could use

sntp_getreachability()

to determine which server was actually used for the synchronization. After having updated to ESP-IDF 5.1 sntp_getreachability() does no longer exist.

My customer wants to know which server was used. Is there a mechanism in 5.1 to find the answer?

Kind regards

Chris

Re: Which SNTP Server was used to synchronize IDF 5.1 and newer

Posted: Mon Jan 15, 2024 2:24 pm
by chruge
Ok, for who ever is intersted...

If you call esp_sntp_getserver(u8_t idx), all servers but the one that time was retrived from, return a 0 for IP address.

I could not find documentation... it's not for granted, that it works reliably.

Re: Which SNTP Server was used to synchronize IDF 5.1 and newer

Posted: Wed Jan 24, 2024 6:20 am
by ESP_cermak
Hi chruge,

I'm sorry, this is actually an omission from our side.

To workaround this problem, you can include these sntp headers, in this order exactly:

Code: Select all

#include "esp_sntp.h"
#undef SNTP_OPMODE_POLL
#include "lwip/apps/sntp.h"
Then you can use the original lwip's `sntp_getreachability()` function as in previous releases. This is also thread safe.

We'll fix this soon and apply the fix to the release branches. Sorry for the inconvenience.