Skip to content

Commit

Permalink
main: init SNTP before starting network
Browse files Browse the repository at this point in the history
If we want to use an NTP server provided by DHCP, sntp_servermode_dhcp()
should be called before the DHCP client requests an IP.
  • Loading branch information
stintel committed Oct 2, 2023
1 parent c453b4c commit 069d5a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ void app_main(void)

ESP_ERROR_CHECK(esp_netif_init());

init_sntp();

esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
// NVS partition was truncated and needs to be erased
Expand Down Expand Up @@ -152,8 +154,6 @@ void app_main(void)
vTaskDelay(portMAX_DELAY);
}

init_sntp();

char *command_endpoint = config_get_char("command_endpoint", DEFAULT_COMMAND_ENDPOINT);
if (strcmp(command_endpoint, "Home Assistant") == 0) {
init_hass();
Expand Down

0 comments on commit 069d5a4

Please sign in to comment.