Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ce18297

Browse files
fix(sntp): Lock / Unlock LWIP if CONFIG_LWIP_TCPIP_CORE_LOCKING is set
Fixes: #10526
1 parent 74e4a74 commit ce18297

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

‎cores/esp32/esp32-hal-time.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
//#include "tcpip_adapter.h"
1818
#include "esp_netif.h"
1919

20+
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
21+
#include "lwip/priv/tcpip_priv.h"
22+
#endif
23+
2024
static void setTimeZone(long offset, int daylight) {
2125
char cst[17] = {0};
2226
char cdt[17] = "DST";
@@ -50,11 +54,23 @@ void configTime(long gmtOffset_sec, int daylightOffset_sec, const char *server1,
5054
if (sntp_enabled()) {
5155
sntp_stop();
5256
}
57+
58+
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
59+
if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER))
60+
LOCK_TCPIP_CORE();
61+
#endif
62+
5363
sntp_setoperatingmode(SNTP_OPMODE_POLL);
54-
sntp_setservername(0, (char *)server1);
64+
sntp_setserwvername(0, (char *)server1);
5565
sntp_setservername(1, (char *)server2);
5666
sntp_setservername(2, (char *)server3);
5767
sntp_init();
68+
69+
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
70+
if (sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER))
71+
UNLOCK_TCPIP_CORE();
72+
#endif
73+
5874
setTimeZone(-gmtOffset_sec, daylightOffset_sec);
5975
}
6076

@@ -68,11 +84,23 @@ void configTzTime(const char *tz, const char *server1, const char *server2, cons
6884
if (sntp_enabled()) {
6985
sntp_stop();
7086
}
87+
88+
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
89+
if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER))
90+
LOCK_TCPIP_CORE();
91+
#endif
92+
7193
sntp_setoperatingmode(SNTP_OPMODE_POLL);
7294
sntp_setservername(0, (char *)server1);
7395
sntp_setservername(1, (char *)server2);
7496
sntp_setservername(2, (char *)server3);
7597
sntp_init();
98+
99+
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
100+
if (sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER))
101+
UNLOCK_TCPIP_CORE();
102+
#endif
103+
76104
setenv("TZ", tz, 1);
77105
tzset();
78106
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /