SNTP with DHCP Static and Dynamic Host

Alberk
Posts: 55
Joined: Sat Jun 19, 2021 1:49 am

SNTP with DHCP Static and Dynamic Host

Postby Alberk » Sun May 12, 2024 7:40 am

Hi,

I would like to understand with is going on with the following code. With the macro

Code: Select all

ESP_NETIF_SNTP_DEFAULT_CONFIG(CONFIG_SNTP_TIME_SERVER);
it should be creating single entry (position zero), then the

Code: Select all

config.index_of_first_server = 1
points to position one, that should crash on setup? Can someone explain to me how this works. Thank you.

https://github.com/espressif/esp-idf/bl ... C3-L160C53

Code: Select all

  ESP_LOGI(TAG, "Initializing SNTP");
    esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG(CONFIG_SNTP_TIME_SERVER);
    config.start = false;                       // start SNTP service explicitly (after connecting)
    config.server_from_dhcp = true;             // accept NTP offers from DHCP server, if any (need to enable *before* connecting)
    config.renew_servers_after_new_IP = true;   // let esp-netif update configured SNTP server(s) after receiving DHCP lease
    config.index_of_first_server = 1;           // updates from server num 1, leaving server 0 (from DHCP) intact
    // configure the event on which we renew servers

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 197 guests