fix(sntp): Lock / Unlock LWIP if CONFIG_LWIP_TCPIP_CORE_LOCKING is set

- Fixes: #10526
- Completes old PR #10529
This commit is contained in:
Mathieu Carbou 2024-12-13 09:09:09 +01:00
parent fb6e977aa8
commit 71396de822
No known key found for this signature in database
GPG key ID: BAAD965CEDEA921A

View file

@ -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);