Which SNTP Server was used to synchronize IDF 5.1 and newer

chruge
Posts: 11
Joined: Fri Jul 21, 2023 8:06 am

Which SNTP Server was used to synchronize IDF 5.1 and newer

Postby chruge » Mon Jan 15, 2024 12:48 pm

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

chruge
Posts: 11
Joined: Fri Jul 21, 2023 8:06 am

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

Postby chruge » Mon Jan 15, 2024 2:24 pm

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.

ESP_cermak
Posts: 69
Joined: Thu Nov 01, 2018 8:32 am

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

Postby ESP_cermak » Wed Jan 24, 2024 6:20 am

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.

Who is online

Users browsing this forum: biakss, cdollar, Google [Bot], sc0ut_, vpascucci and 208 guests