From 3778c0a8ffdbf21305637aa50361a148015230a4 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 20:36:49 +1100 Subject: [PATCH 1/4] * repeater and room server: MESH_PACKET_LOGGING, now dumps RAW: rx packet contents * Dispatcher: MESH_PACKET_LOGGING, added " hash={packet-hash}" --- examples/simple_repeater/main.cpp | 9 +++++++++ examples/simple_room_server/main.cpp | 9 +++++++++ platformio.ini | 2 +- src/Dispatcher.cpp | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 55dbe3f7..b20354aa 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -246,6 +246,15 @@ protected: return tmp; } + void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) override { + #if MESH_PACKET_LOGGING + Serial.print(getLogDateTime()); + Serial.print(" RAW: "); + mesh::Utils::printHex(Serial, raw, len); + Serial.println(); + #endif + } + void logRx(mesh::Packet* pkt, int len, float score) override { if (_logging) { File f = openAppend(PACKET_LOG_FILE); diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 339e580e..131343a6 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -264,6 +264,15 @@ protected: return _prefs.airtime_factor; } + void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) override { + #if MESH_PACKET_LOGGING + Serial.print(getLogDateTime()); + Serial.print(" RAW: "); + mesh::Utils::printHex(Serial, raw, len); + Serial.println(); + #endif + } + int calcRxDelay(float score, uint32_t air_time) const override { if (_prefs.rx_delay_base <= 0.0f) return 0; return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time); diff --git a/platformio.ini b/platformio.ini index e6e1f53c..205bb701 100644 --- a/platformio.ini +++ b/platformio.ini @@ -159,7 +159,7 @@ build_flags = -D ADVERT_LON=145.0 -D ADMIN_PASSWORD="\"password\"" -D ROOM_PASSWORD="\"hello\"" -; -D MESH_PACKET_LOGGING=1 + -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 [env:Heltec_v3_terminal_chat] diff --git a/src/Dispatcher.cpp b/src/Dispatcher.cpp index e4943254..dffabcc3 100644 --- a/src/Dispatcher.cpp +++ b/src/Dispatcher.cpp @@ -130,6 +130,12 @@ void Dispatcher::checkRecv() { Serial.printf(": RX, len=%d (type=%d, route=%s, payload_len=%d) SNR=%d RSSI=%d score=%d", 2 + pkt->path_len + pkt->payload_len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len, (int)_radio->getLastSNR(), (int)_radio->getLastRSSI(), (int)(score*1000)); + + static uint8_t packet_hash[MAX_HASH_SIZE]; + pkt->calculatePacketHash(packet_hash); + Serial.print(" hash="); + mesh::Utils::printHex(Serial, packet_hash, MAX_HASH_SIZE); + if (pkt->getPayloadType() == PAYLOAD_TYPE_PATH || pkt->getPayloadType() == PAYLOAD_TYPE_REQ || pkt->getPayloadType() == PAYLOAD_TYPE_RESPONSE || pkt->getPayloadType() == PAYLOAD_TYPE_TXT_MSG) { Serial.printf(" [%02X -> %02X]\n", (uint32_t)pkt->payload[1], (uint32_t)pkt->payload[0]); From a259d27cfed84d1506fbb1d3ac69c6530c567316 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 22:15:58 +1100 Subject: [PATCH 2/4] * trying setCRC(1) --- examples/companion_radio/main.cpp | 2 +- examples/simple_repeater/main.cpp | 2 +- examples/simple_room_server/main.cpp | 2 +- examples/simple_secure_chat/main.cpp | 2 +- src/helpers/RadioLibWrappers.cpp | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 10eca8c9..b25445c0 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1265,7 +1265,7 @@ void setup() { halt(); } - radio.setCRC(0); + radio.setCRC(1); #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index b20354aa..703c989f 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -689,7 +689,7 @@ void setup() { halt(); } - radio.setCRC(0); + radio.setCRC(1); #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 131343a6..0c1fb135 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -743,7 +743,7 @@ void setup() { halt(); } - radio.setCRC(0); + radio.setCRC(1); #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index 1f854773..951d51dc 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -585,7 +585,7 @@ void setup() { halt(); } - radio.setCRC(0); + radio.setCRC(1); #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); diff --git a/src/helpers/RadioLibWrappers.cpp b/src/helpers/RadioLibWrappers.cpp index 8d133ccd..03f8f3ce 100644 --- a/src/helpers/RadioLibWrappers.cpp +++ b/src/helpers/RadioLibWrappers.cpp @@ -52,10 +52,11 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) { int err = _radio->readData(bytes, len); if (err != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("RadioLibWrapper: error: readData(%d)", err); + len = 0; } else { // Serial.print(" readData() -> "); Serial.println(len); + n_recv++; } - n_recv++; } state = STATE_IDLE; // need another startReceive() return len; From 291b98cd56c6c2bbf4236679a3d8ff1dd6cd1c7b Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 23:44:34 +1100 Subject: [PATCH 3/4] updating RadioLib to ver 7.1.2 --- platformio.ini | 2 +- src/helpers/CustomSX1262.h | 2 +- src/helpers/CustomSX1268.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 205bb701..bc26d65c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,7 +14,7 @@ monitor_speed = 115200 lib_deps = SPI Wire - jgromes/RadioLib @ ^6.3.0 + jgromes/RadioLib @ ^7.1.2 rweather/Crypto @ ^0.4.0 adafruit/RTClib @ ^2.1.3 melopero/Melopero RV3028 @ ^1.1.0 diff --git a/src/helpers/CustomSX1262.h b/src/helpers/CustomSX1262.h index 6f66d129..70a1077f 100644 --- a/src/helpers/CustomSX1262.h +++ b/src/helpers/CustomSX1262.h @@ -9,7 +9,7 @@ class CustomSX1262 : public SX1262 { CustomSX1262(Module *mod) : SX1262(mod) { } bool isReceiving() { - uint16_t irq = getIrqStatus(); + uint16_t irq = getIrqFlags(); bool hasPreamble = (irq & SX126X_IRQ_HEADER_VALID); return hasPreamble; } diff --git a/src/helpers/CustomSX1268.h b/src/helpers/CustomSX1268.h index 46ce922a..50024693 100644 --- a/src/helpers/CustomSX1268.h +++ b/src/helpers/CustomSX1268.h @@ -9,7 +9,7 @@ class CustomSX1268 : public SX1268 { CustomSX1268(Module *mod) : SX1268(mod) { } bool isReceiving() { - uint16_t irq = getIrqStatus(); + uint16_t irq = getIrqFlags(); bool hasPreamble = (irq & SX126X_IRQ_HEADER_VALID); return hasPreamble; } From 2cb742b1004cb1d86004a9502b51ef6404b4b39d Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 23:46:03 +1100 Subject: [PATCH 4/4] ver bump to 1.2.2 --- examples/companion_radio/main.cpp | 4 ++-- examples/simple_repeater/main.cpp | 4 ++-- examples/simple_room_server/main.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index b25445c0..833e41d8 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -120,11 +120,11 @@ static uint32_t _atoi(const char* sp) { #define FIRMWARE_VER_CODE 2 #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "7 Mar 2025" + #define FIRMWARE_BUILD_DATE "9 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.1" + #define FIRMWARE_VERSION "v1.2.2" #endif #define CMD_APP_START 1 diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 703c989f..5743647b 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -22,11 +22,11 @@ /* ------------------------------ Config -------------------------------- */ #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "7 Mar 2025" + #define FIRMWARE_BUILD_DATE "9 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.1" + #define FIRMWARE_VERSION "v1.2.2" #endif #ifndef LORA_FREQ diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 0c1fb135..cde56c47 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -22,11 +22,11 @@ /* ------------------------------ Config -------------------------------- */ #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "7 Mar 2025" + #define FIRMWARE_BUILD_DATE "9 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.1" + #define FIRMWARE_VERSION "v1.2.2" #endif #ifndef LORA_FREQ