SNTP with DHCP Static and Dynamic Host
Posted: Sun May 12, 2024 7:40 am
Hi,
I would like to understand with is going on with the following code. With the macro it should be creating single entry (position zero), then the 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
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);
Code: Select all
config.index_of_first_server = 1
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