From 71396de822b6c8734839462ed87bd3c6a5d43143 Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Fri, 13 Dec 2024 09:09:09 +0100 Subject: [PATCH] fix(sntp): Lock / Unlock LWIP if CONFIG_LWIP_TCPIP_CORE_LOCKING is set - Fixes: #10526 - Completes old PR #10529 --- cores/esp32/esp32-hal-time.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cores/esp32/esp32-hal-time.c b/cores/esp32/esp32-hal-time.c index 25c060eabdd..074e999be71 100644 --- a/cores/esp32/esp32-hal-time.c +++ b/cores/esp32/esp32-hal-time.c @@ -51,9 +51,6 @@ static void setTimeZone(long offset, int daylight) { void configTime(long gmtOffset_sec, int daylightOffset_sec, const char *server1, const char *server2, const char *server3) { //tcpip_adapter_init(); // Should not hurt anything if already inited esp_netif_init(); - if (sntp_enabled()) { - sntp_stop(); - } #ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) { @@ -61,6 +58,10 @@ void configTime(long gmtOffset_sec, int daylightOffset_sec, const char *server1, } #endif + if (sntp_enabled()) { + sntp_stop(); + } + sntp_setoperatingmode(SNTP_OPMODE_POLL); sntp_setservername(0, (char *)server1); sntp_setservername(1, (char *)server2); @@ -83,9 +84,6 @@ void configTime(long gmtOffset_sec, int daylightOffset_sec, const char *server1, void configTzTime(const char *tz, const char *server1, const char *server2, const char *server3) { //tcpip_adapter_init(); // Should not hurt anything if already inited esp_netif_init(); - if (sntp_enabled()) { - sntp_stop(); - } #ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) { @@ -93,6 +91,10 @@ void configTzTime(const char *tz, const char *server1, const char *server2, cons } #endif + if (sntp_enabled()) { + sntp_stop(); + } + sntp_setoperatingmode(SNTP_OPMODE_POLL); sntp_setservername(0, (char *)server1); sntp_setservername(1, (char *)server2);