Skip to content

Commit 489e8de

Browse files
committed
ethernet: enable SNTP and timezone
The Ethernet path skipped the shared SNTP lifecycle, so it neither applied the configured timezone nor synchronized the system clock. Expose the helpers and initialize SNTP before bringing up the W5500 interface. Start it after the existing connection wait. The shared configuration already selects the Ethernet IP event.
1 parent eb3b58c commit 489e8de

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

main/net/ethernet.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ esp_err_t init_ethernet(void)
8383
{
8484
esp_err_t ret = ESP_OK;
8585

86+
init_sntp();
87+
8688
// Start Ethernet
8789
if (lvgl_port_lock(lvgl_lock_timeout)) {
8890
lv_obj_clear_flag(lbl_ln4, LV_OBJ_FLAG_HIDDEN);
@@ -188,5 +190,7 @@ esp_err_t init_ethernet(void)
188190
// HACK
189191
vTaskDelay(5000 / portTICK_PERIOD_MS);
190192

193+
start_sntp();
194+
191195
return ret;
192196
}

main/network.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void set_hostname(esp_netif_t *netif, esp_mac_type_t mac_type)
7171
}
7272
}
7373

74-
static esp_err_t init_sntp(void)
74+
esp_err_t init_sntp(void)
7575
{
7676
ESP_LOGI(TAG, "initializing SNTP client");
7777
esp_err_t ret = ESP_OK;
@@ -95,7 +95,7 @@ static esp_err_t init_sntp(void)
9595
return ret;
9696
}
9797

98-
static esp_err_t start_sntp(void)
98+
esp_err_t start_sntp(void)
9999
{
100100
char *ntp_config = config_get_char("ntp_config", DEFAULT_NTP_CONFIG);
101101
if (strcmp(ntp_config, "DHCP") == 0) {

main/network.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ extern esp_netif_t *hdl_netif;
55

66
esp_err_t init_wifi(const char *psk, const char *ssid);
77
esp_err_t init_ethernet(void);
8+
esp_err_t init_sntp(void);
9+
esp_err_t start_sntp(void);
810
void get_mac_address(void);
911
void set_hostname(esp_netif_t *netif, esp_mac_type_t mac_type);

0 commit comments

Comments
 (0)