From 083dcef9d6d03c27b873e150948f84247b8ea7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 23 Jan 2023 16:49:45 +0100 Subject: [PATCH 1/5] don't define default pins for these. --- src/modules/SerialModule.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index d740ba607..5637f7eb1 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -12,7 +12,7 @@ A simple interface to send messages over the mesh network by sending strings over a serial port. - Default is to use RX GPIO 16 and TX GPIO 17. + There are no PIN defaults, you have to enable the second serial port yourself. Need help with this module? Post your question on the Meshtastic Discourse: https://meshtastic.discourse.group @@ -46,8 +46,6 @@ #if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) -#define RXD2 16 -#define TXD2 17 #define RX_BUFFER 128 #define TIMEOUT 250 #define BAUD 38400 @@ -102,7 +100,7 @@ int32_t SerialModule::runOnce() // moduleConfig.serial.timeout = 1000; // moduleConfig.serial.echo = 1; - if (moduleConfig.serial.enabled) { + if (moduleConfig.serial.enabled && moduleConfig.serial.rxd && moduleConfig.serial.txd) { if (firstTime) { @@ -165,9 +163,6 @@ int32_t SerialModule::runOnce() if (moduleConfig.serial.rxd && moduleConfig.serial.txd) { Serial2.begin(baud, SERIAL_8N1, moduleConfig.serial.rxd, moduleConfig.serial.txd); - - } else { - Serial2.begin(baud, SERIAL_8N1, RXD2, TXD2); } #else if (moduleConfig.serial.rxd && moduleConfig.serial.txd) From 81854a173abbbfe695f74f5668c6977b5fa64440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 23 Jan 2023 21:29:46 +0100 Subject: [PATCH 2/5] fix #2109 json mqtt on secondary channel --- .vscode/extensions.json | 7 ++++--- src/mqtt/MQTT.cpp | 8 +++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 4fc84fa78..080e70d08 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,8 +2,9 @@ // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format "recommendations": [ - "ms-vscode.cpptools", - "platformio.platformio-ide", - "trunk.io" + "platformio.platformio-ide" ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] } diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 42dad45bb..5e32050ad 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -53,10 +53,8 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length) for (int i = 0; i < 3; i++) { ptr = strtok(NULL, "/"); } - LOG_DEBUG("Looking for Channel name: %s\n", ptr); meshtastic_Channel sendChannel = channels.getByName(ptr); - LOG_DEBUG("Found Channel name: %s (Index %d)\n", channels.getGlobalId(sendChannel.settings.channel_num), - sendChannel.settings.channel_num); + LOG_DEBUG("Found Channel name: %s (Index %d)\n", channels.getGlobalId(sendChannel.index), sendChannel.index); if ((json.find("sender") != json.end()) && (json.find("payload") != json.end()) && (json.find("type") != json.end()) && json["type"]->IsString() && @@ -70,7 +68,7 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length) // construct protobuf data packet using TEXT_MESSAGE, send it to the mesh meshtastic_MeshPacket *p = router->allocForSending(); p->decoded.portnum = meshtastic_PortNum_TEXT_MESSAGE_APP; - p->channel = sendChannel.settings.channel_num; + p->channel = sendChannel.index; if (sendChannel.settings.downlink_enabled) { if (jsonPayloadStr.length() <= sizeof(p->decoded.payload.bytes)) { memcpy(p->decoded.payload.bytes, jsonPayloadStr.c_str(), jsonPayloadStr.length()); @@ -104,7 +102,7 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length) // construct protobuf data packet using POSITION, send it to the mesh meshtastic_MeshPacket *p = router->allocForSending(); p->decoded.portnum = meshtastic_PortNum_POSITION_APP; - p->channel = sendChannel.settings.channel_num; + p->channel = sendChannel.index; if (sendChannel.settings.downlink_enabled) { p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), From e8186f7dba425355e89db826c1321cd5c35af949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 23 Jan 2023 21:36:22 +0100 Subject: [PATCH 3/5] how did that sneak in? --- .vscode/extensions.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 080e70d08..4fc84fa78 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,9 +2,8 @@ // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format "recommendations": [ - "platformio.platformio-ide" + "ms-vscode.cpptools", + "platformio.platformio-ide", + "trunk.io" ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] } From 19d864b5cec76dd8aaa78f79b1edc0db5923ac87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 23 Jan 2023 22:20:34 +0100 Subject: [PATCH 4/5] Also reboot if no heap debugging enabled --- src/concurrency/OSThread.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/concurrency/OSThread.cpp b/src/concurrency/OSThread.cpp index 4a46c7b0e..c5e60f6fb 100644 --- a/src/concurrency/OSThread.cpp +++ b/src/concurrency/OSThread.cpp @@ -1,7 +1,8 @@ #include "OSThread.h" #include "configuration.h" -#ifdef DEBUG_HEAP +#ifdef HAS_SCREEN #include "graphics/Screen.h" +#endif #include "main.h" #endif #include @@ -83,18 +84,21 @@ void OSThread::run() #endif currentThread = this; auto newDelay = runOnce(); -#ifdef DEBUG_HEAP +#ifdef ARCH_ESP32 auto newHeap = ESP.getFreeHeap(); + if (newHeap < 10000) { + LOG_DEBUG("\n\n====== heap too low [10000] -> reboot in 5s ======\n\n"); +#ifdef HAS_SCREEN + screen->startRebootScreen(); +#endif + rebootAtMsec = millis() + 5000; + } +#ifdef DEBUG_HEAP if (newHeap < heap) LOG_DEBUG("------ Thread %s leaked heap %d -> %d (%d) ------\n", ThreadName.c_str(), heap, newHeap, newHeap - heap); if (heap < newHeap) LOG_DEBUG("++++++ Thread %s freed heap %d -> %d (%d) ++++++\n", ThreadName.c_str(), heap, newHeap, newHeap - heap); - - if (newHeap < 10000) { - LOG_DEBUG("\n\n====== heap too low [10000] -> reboot in 5s ======\n\n"); - screen->startRebootScreen(); - rebootAtMsec = millis() + 5000; - } +#endif #endif runned(); From afb4d141dc61eb424bdfe462e6b7483a940a79bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 23 Jan 2023 22:24:29 +0100 Subject: [PATCH 5/5] remove double endif --- src/concurrency/OSThread.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/concurrency/OSThread.cpp b/src/concurrency/OSThread.cpp index c5e60f6fb..c52efd626 100644 --- a/src/concurrency/OSThread.cpp +++ b/src/concurrency/OSThread.cpp @@ -4,7 +4,6 @@ #include "graphics/Screen.h" #endif #include "main.h" -#endif #include namespace concurrency