The call to esp_sntp_setservername does not seem to work.

User avatar
MickPF
Posts: 62
Joined: Tue Apr 03, 2018 8:47 pm

Re: The call to esp_sntp_setservername does not seem to work.

Postby MickPF » Fri Jan 02, 2026 3:58 pm

MicroController's suggestion

Code: Select all

   esp_sntp_config_t sntp_config = ESP_NETIF_SNTP_DEFAULT_CONFIG_MULTIPLE(
                               3,
                               ESP_SNTP_SERVER_LIST( NULL, NULL, NULL ) );
was not tested by him. The following warning appeared during code compilation:

Code: Select all

/home/mick/Projects/ESP-IDF/eve/components/wifi/wifi.c: In function 'wifi_init':
/home/mick/Projects/ESP-IDF/eve/components/wifi/wifi.c:653:49: warning: excess elements in array initializer
  653 |                 esp_sntp_config_t sntp_config = ESP_NETIF_SNTP_DEFAULT_CONFIG_MULTIPLE(3,
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mick/Projects/ESP-IDF/eve/components/wifi/wifi.c:653:49: note: (near initialization for 'sntp_config.servers')
/home/mick/Projects/ESP-IDF/eve/components/wifi/wifi.c:653:49: warning: excess elements in array initializer
/home/mick/Projects/ESP-IDF/eve/components/wifi/wifi.c:653:49: note: (near initialization for 'sntp_config.servers')
and subsequently, the error message occurred at runtime:

Code: Select all

E (3287) esp_netif_sntp: sntp_init_api(48): Tried to configure more servers than enabled in lwip. Please update CONFIG_SNTP_MAX_SERVERS
E (3297) esp_netif_sntp: esp_netif_sntp_init(119): Failed initialize SNTP service
Setting NTP servers via the call esp_sntp_setservername after executing the call esp_netif_sntp_init leads to the output

Code: Select all

I (3307) WIFI: NTP server no. 0 : <NULL>
I (3307) WIFI: NTP server no. 1 : <NULL>
I have the feeling that workarounds are being suggested here for a bug, but they all lead nowhere.

I will have to "live" with using only one NTP server!

Given the way this discussion is going, I've decided to end it!

MicroController
Posts: 2661
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: The call to esp_sntp_setservername does not seem to work.

Postby MicroController » Fri Jan 02, 2026 4:37 pm

Given the way this discussion is going, I've decided to end it!
Ok.

For anybody else interested in the future:
Make sure you have CONFIG_LWIP_DHCP_MAX_NTP_SERVERS or CONFIG_LWIP_SNTP_MAX_SERVERS set to at least the number of servers you intend to use.

User avatar
MickPF
Posts: 62
Joined: Tue Apr 03, 2018 8:47 pm

Re: The call to esp_sntp_setservername does not seem to work.

Postby MickPF » Fri Jan 02, 2026 4:58 pm

Now I have to apologize, especially to MicroController: Even though I searched through the settings several times, I missed this option!

Sorry, shit happens.

Now it works.

Who is online

Users browsing this forum: Bytespider, ChatGPT-User, Qwantbot, YisouSpider and 14 guests