Skip to content

Commit 71396de

Browse files
committed
fix(sntp): Lock / Unlock LWIP if CONFIG_LWIP_TCPIP_CORE_LOCKING is set
- Fixes: #10526 - Completes old PR #10529
1 parent fb6e977 commit 71396de

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cores/esp32/esp32-hal-time.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,17 @@ static void setTimeZone(long offset, int daylight) {
5151
void configTime(long gmtOffset_sec, int daylightOffset_sec, const char *server1, const char *server2, const char *server3) {
5252
//tcpip_adapter_init(); // Should not hurt anything if already inited
5353
esp_netif_init();
54-
if (sntp_enabled()) {
55-
sntp_stop();
56-
}
5754

5855
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
5956
if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) {
6057
LOCK_TCPIP_CORE();
6158
}
6259
#endif
6360

61+
if (sntp_enabled()) {
62+
sntp_stop();
63+
}
64+
6465
sntp_setoperatingmode(SNTP_OPMODE_POLL);
6566
sntp_setservername(0, (char *)server1);
6667
sntp_setservername(1, (char *)server2);
@@ -83,16 +84,17 @@ void configTime(long gmtOffset_sec, int daylightOffset_sec, const char *server1,
8384
void configTzTime(const char *tz, const char *server1, const char *server2, const char *server3) {
8485
//tcpip_adapter_init(); // Should not hurt anything if already inited
8586
esp_netif_init();
86-
if (sntp_enabled()) {
87-
sntp_stop();
88-
}
8987

9088
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
9189
if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) {
9290
LOCK_TCPIP_CORE();
9391
}
9492
#endif
9593

94+
if (sntp_enabled()) {
95+
sntp_stop();
96+
}
97+
9698
sntp_setoperatingmode(SNTP_OPMODE_POLL);
9799
sntp_setservername(0, (char *)server1);
98100
sntp_setservername(1, (char *)server2);

0 commit comments

Comments
 (0)