From 52d85c9a41819fc3edbb5825a44664ac8cc86da3 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 27 Feb 2021 22:34:53 -0800 Subject: [PATCH 1/5] Partial work from laptop -- non-routers can send a heartbeat --- src/plugins/esp32/StoreForwardPlugin.cpp | 20 +++++++++++++++----- src/plugins/esp32/StoreForwardPlugin.h | 5 +++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/plugins/esp32/StoreForwardPlugin.cpp b/src/plugins/esp32/StoreForwardPlugin.cpp index 0550b7af0..031f32b4f 100644 --- a/src/plugins/esp32/StoreForwardPlugin.cpp +++ b/src/plugins/esp32/StoreForwardPlugin.cpp @@ -66,12 +66,13 @@ int32_t StoreForwardPlugin::runOnce() } } else { - DEBUG_MSG("Initializing Store & Forward Plugin - Enabled but is_router is not turned on.\n"); - DEBUG_MSG( - "Initializing Store & Forward Plugin - If you want to use this plugin, you must also turn on is_router.\n"); - // Non-Router + /* + * If the plugin is turned on and is_router is not enabled, then we'll send a heartbeat every + * few minutes. + */ + storeForwardPluginRadio->sendPayloadHeartbeat(); - return (30 * 1000); + return (3 * 60 * 1000); } } else { @@ -235,6 +236,15 @@ void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies) service.sendToMesh(p); } +void StoreForwardPluginRadio::sendPayloadHeartbeat(NodeNum dest, bool wantReplies) +{ + MeshPacket *p = allocReply(); + p->to = dest; + p->decoded.want_response = wantReplies; + + service.sendToMesh(p); +} + bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 diff --git a/src/plugins/esp32/StoreForwardPlugin.h b/src/plugins/esp32/StoreForwardPlugin.h index e49b38fe9..d2a2879c8 100644 --- a/src/plugins/esp32/StoreForwardPlugin.h +++ b/src/plugins/esp32/StoreForwardPlugin.h @@ -63,6 +63,11 @@ class StoreForwardPluginRadio : public SinglePortPlugin */ void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + /** + * Send our payload into the mesh + */ + void sendPayloadHeartbeat(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + protected: virtual MeshPacket *allocReply(); From ef32ac5cd4e4694792025bc1a9b51ea7708fb0f7 Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 28 Feb 2021 11:55:54 -0800 Subject: [PATCH 2/5] Update rangetest docs with api example --- docs/software/plugins/RangeTestPlugin.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/software/plugins/RangeTestPlugin.md b/docs/software/plugins/RangeTestPlugin.md index ee7732175..ab2f2c4df 100644 --- a/docs/software/plugins/RangeTestPlugin.md +++ b/docs/software/plugins/RangeTestPlugin.md @@ -45,6 +45,18 @@ Recommended settings for a sender at different radio settings: Medium ... range_test_plugin_sender = 15 Short Fast ... range_test_plugin_sender = 15 +## Python API Examples + +### Sender + + meshtastic --set range_test_plugin_enabled 1 + meshtastic --set range_test_plugin_sender 60 + +### Receiver + + meshtastic --set range_test_plugin_enabled 1 + meshtastic --set range_test_plugin_save 1 + ## Other things to keep in mind Be sure to turn off either the plugin configured as a sender or the device where the plugin setup as sender when not in use. This will use a lot of time on air and will spam your channel. From 2cf704abe09b4267e0a62aa57741294392f22e58 Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 28 Feb 2021 19:35:00 -0800 Subject: [PATCH 3/5] Crashes after 7 seconds. --- src/plugins/esp32/StoreForwardPlugin.cpp | 67 ++++++++++++++---------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/src/plugins/esp32/StoreForwardPlugin.cpp b/src/plugins/esp32/StoreForwardPlugin.cpp index 031f32b4f..ff763130c 100644 --- a/src/plugins/esp32/StoreForwardPlugin.cpp +++ b/src/plugins/esp32/StoreForwardPlugin.cpp @@ -26,26 +26,23 @@ int32_t StoreForwardPlugin::runOnce() without having to configure it from the PythonAPI or WebUI. */ - // radioConfig.preferences.store_forward_plugin_enabled = 1; - // radioConfig.preferences.is_router = 1; + radioConfig.preferences.store_forward_plugin_enabled = 1; + radioConfig.preferences.is_router = 0; if (radioConfig.preferences.store_forward_plugin_enabled) { if (firstTime) { - /* - */ + firstTime = 0; if (radioConfig.preferences.is_router) { - DEBUG_MSG("Initializing Store & Forward Plugin - Enabled\n"); + DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Router\n"); // Router if (ESP.getPsramSize()) { if (ESP.getFreePsram() >= 2048 * 1024) { // Do the startup here storeForwardPluginRadio = new StoreForwardPluginRadio(); - firstTime = 0; - this->populatePSRAM(); // packetHistory[0].bytes; @@ -66,22 +63,30 @@ int32_t StoreForwardPlugin::runOnce() } } else { - /* - * If the plugin is turned on and is_router is not enabled, then we'll send a heartbeat every - * few minutes. - */ - storeForwardPluginRadio->sendPayloadHeartbeat(); - - return (3 * 60 * 1000); + DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Client\n"); + return (5 * 1000); } } else { - // What do we do if it's not our first time? - // Maybe some cleanup functions? - this->sawNodeReport(); - this->historyReport(); - return (10 * 1000); + if (radioConfig.preferences.is_router) { + // Maybe some cleanup functions? + this->sawNodeReport(); + this->historyReport(); + return (10 * 1000); + } else { + /* + * If the plugin is turned on and is_router is not enabled, then we'll send a heartbeat every + * few minutes. + */ + + DEBUG_MSG("Store & Forward Plugin - Sending heartbeat\n"); + + // storeForwardPluginRadio->sendPayloadHeartbeat(); + storeForwardPluginRadio->sendPayload(); + + return (1 * 60 * 1000); + } } } else { @@ -221,24 +226,32 @@ void StoreForwardPlugin::sawNodeReport() MeshPacket *StoreForwardPluginRadio::allocReply() { - - auto reply = allocDataPacket(); // Allocate a packet for sending - - return reply; + //auto reply = allocDataPacket(); // Allocate a packet for sending + //return reply; } void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies) { - MeshPacket *p = allocReply(); + MeshPacket *p = this->allocReply(); + /* p->to = dest; p->decoded.want_response = wantReplies; - service.sendToMesh(p); + p->want_ack = true; +*/ + // static char heartbeatString[20]; + // snprintf(heartbeatString, sizeof(heartbeatString), "1"); + + // p->decoded.data.payload.size = strlen(heartbeatString); // You must specify how many bytes are in the reply + // memcpy(p->decoded.data.payload.bytes, "1", 1); + + // service.sendToMesh(p); } void StoreForwardPluginRadio::sendPayloadHeartbeat(NodeNum dest, bool wantReplies) { - MeshPacket *p = allocReply(); + DEBUG_MSG("Sending S&F Heartbeat\n"); + MeshPacket *p = this->allocReply(); p->to = dest; p->decoded.want_response = wantReplies; @@ -292,7 +305,7 @@ bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp) } if ((millis() - sawTime) > STOREFORWARD_SEND_HISTORY_SHORT) { - // Node has been away for a while. + // Node has been away for a while. storeForwardPlugin->historySend(sawTime, mp.from); } } From a3343bc1af13931e6c68d6578e95486b76db90e3 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 2 Mar 2021 20:46:21 -0800 Subject: [PATCH 4/5] Revert "Merge pull request #73 from meshtastic/master" This reverts commit ee04d57a7f4ec94c6ba8a872d6b1ffb5aa96c562. From 2f7c2a2aead2a95e35c30741372cf13c138634eb Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Tue, 9 Mar 2021 16:16:41 +1100 Subject: [PATCH 5/5] Update main.yml --- .github/workflows/main.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9c9b2fffd..dcbb213b5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,11 +7,12 @@ jobs: setup: runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - name: Checkout submodules - uses: textbook/git-checkout-submodule-action@master + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: true - name: Setup Python - uses: actions/setup-python@master + uses: actions/setup-python@v2 with: python-version: 3.x - name: Install Platform IO @@ -31,4 +32,4 @@ jobs: - name: Build for lora-relay-v1 run: platformio run -e lora-relay-v1 - name: Build for linux - run: platformio run -e linux \ No newline at end of file + run: platformio run -e linux