Page 2 of 2

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

Posted: Fri Jan 02, 2026 3:58 pm
by MickPF
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!

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

Posted: Fri Jan 02, 2026 4:37 pm
by MicroController
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.

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

Posted: Fri Jan 02, 2026 4:58 pm
by MickPF
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.