Skip to content

Commit 8db3c25

Browse files
committed
Bugfix:Crash with "Required to lock TCPIP core functionality!)" because of Arduino Core 3.1.0 RC2 bug
See: espressif/arduino-esp32#10526
1 parent 56eb7ba commit 8db3c25

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

.clang-format

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ Language: Cpp
22
BasedOnStyle: LLVM
33

44
AccessModifierOffset: -2
5+
AlignConsecutiveMacros: true
6+
AllowAllArgumentsOnNextLine: false
7+
AllowAllParametersOfDeclarationOnNextLine: false
58
AllowShortIfStatementsOnASingleLine: false
9+
AllowShortLambdasOnASingleLine: Inline
10+
BinPackArguments: false
611
ColumnLimit: 0
712
ContinuationIndentWidth: 2
813
FixNamespaceComments: false
914
IndentAccessModifiers: true
1015
IndentCaseLabels: true
16+
IndentPPDirectives: BeforeHash
1117
IndentWidth: 2
1218
NamespaceIndentation: All
1319
PointerAlignment: Left
1420
ReferenceAlignment: Left
1521
TabWidth: 2
16-
UseTab: Never
22+
UseTab: Never

src/MycilaNTP.cpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@
88
#include <Arduino.h>
99
#include <sys/time.h>
1010

11+
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
12+
#include "lwip/priv/tcpip_priv.h"
13+
#endif
14+
1115
#ifdef MYCILA_LOGGER_SUPPORT
12-
#include <MycilaLogger.h>
16+
#include <MycilaLogger.h>
1317
extern Mycila::Logger logger;
14-
#define LOGD(tag, format, ...) logger.debug(tag, format, ##__VA_ARGS__)
15-
#define LOGI(tag, format, ...) logger.info(tag, format, ##__VA_ARGS__)
16-
#define LOGW(tag, format, ...) logger.warn(tag, format, ##__VA_ARGS__)
17-
#define LOGE(tag, format, ...) logger.error(tag, format, ##__VA_ARGS__)
18+
#define LOGD(tag, format, ...) logger.debug(tag, format, ##__VA_ARGS__)
19+
#define LOGI(tag, format, ...) logger.info(tag, format, ##__VA_ARGS__)
20+
#define LOGW(tag, format, ...) logger.warn(tag, format, ##__VA_ARGS__)
21+
#define LOGE(tag, format, ...) logger.error(tag, format, ##__VA_ARGS__)
1822
#else
19-
#define LOGD(tag, format, ...) ESP_LOGD(tag, format, ##__VA_ARGS__)
20-
#define LOGI(tag, format, ...) ESP_LOGI(tag, format, ##__VA_ARGS__)
21-
#define LOGW(tag, format, ...) ESP_LOGW(tag, format, ##__VA_ARGS__)
22-
#define LOGE(tag, format, ...) ESP_LOGE(tag, format, ##__VA_ARGS__)
23+
#define LOGD(tag, format, ...) ESP_LOGD(tag, format, ##__VA_ARGS__)
24+
#define LOGI(tag, format, ...) ESP_LOGI(tag, format, ##__VA_ARGS__)
25+
#define LOGW(tag, format, ...) ESP_LOGW(tag, format, ##__VA_ARGS__)
26+
#define LOGE(tag, format, ...) ESP_LOGE(tag, format, ##__VA_ARGS__)
2327
#endif
2428

2529
#define TAG "NTP"
@@ -63,7 +67,18 @@ bool Mycila::NTPClass::sync(const char* server, const uint8_t retryInterval) {
6367
_server = server;
6468
_ticker.detach();
6569

70+
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
71+
if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER))
72+
LOCK_TCPIP_CORE();
73+
#endif
74+
6675
configTime(0, 0, _server.c_str());
76+
77+
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
78+
if (sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER))
79+
UNLOCK_TCPIP_CORE();
80+
#endif
81+
6782
if (!_spec.isEmpty()) {
6883
setenv("TZ", _spec.c_str(), 1);
6984
tzset();
@@ -75,7 +90,8 @@ bool Mycila::NTPClass::sync(const char* server, const uint8_t retryInterval) {
7590
if (!_synced) {
7691
LOGI(TAG, "Syncing time with %s", _server.c_str());
7792
_ticker.attach(
78-
retryInterval, +[](NTPClass* instance) {
93+
retryInterval,
94+
+[](NTPClass* instance) {
7995
// Serial.println("NTP Tick");
8096
if (!instance->_synced) {
8197
struct tm timeInfo;

src/MycilaNTP.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
#include <functional>
1212

1313
#ifdef MYCILA_JSON_SUPPORT
14-
#include <ArduinoJson.h>
14+
#include <ArduinoJson.h>
1515
#endif
1616

17-
#define MYCILA_NTP_VERSION "5.0.0"
18-
#define MYCILA_NTP_VERSION_MAJOR 5
19-
#define MYCILA_NTP_VERSION_MINOR 0
17+
#define MYCILA_NTP_VERSION "5.0.0"
18+
#define MYCILA_NTP_VERSION_MAJOR 5
19+
#define MYCILA_NTP_VERSION_MINOR 0
2020
#define MYCILA_NTP_VERSION_REVISION 0
2121

2222
#ifndef MYCILA_NTP_RETRY_INTERVAL
23-
#define MYCILA_NTP_RETRY_INTERVAL 2
23+
#define MYCILA_NTP_RETRY_INTERVAL 2
2424
#endif
2525

2626
namespace Mycila {

0 commit comments

Comments
 (0)