From 24329a26dee2f09c11c491a597f247678ba46ac4 Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 14 Feb 2021 14:01:08 -0800 Subject: [PATCH] Framework for storeforward --- src/plugins/RangeTestPlugin.cpp | 1 - src/plugins/StoreForwardPlugin.cpp | 65 +++++------------------------- src/plugins/StoreForwardPlugin.h | 12 ++---- 3 files changed, 12 insertions(+), 66 deletions(-) diff --git a/src/plugins/RangeTestPlugin.cpp b/src/plugins/RangeTestPlugin.cpp index f8e4f53de..a1c69b101 100644 --- a/src/plugins/RangeTestPlugin.cpp +++ b/src/plugins/RangeTestPlugin.cpp @@ -41,7 +41,6 @@ int32_t RangeTestPlugin::runOnce() // Fixed position is useful when testing indoors. // radioConfig.preferences.fixed_position = 1; - uint32_t senderHeartbeat = radioConfig.preferences.range_test_plugin_sender * 1000; if (radioConfig.preferences.range_test_plugin_enabled) { diff --git a/src/plugins/StoreForwardPlugin.cpp b/src/plugins/StoreForwardPlugin.cpp index 633aaa5ec..2db4d7358 100644 --- a/src/plugins/StoreForwardPlugin.cpp +++ b/src/plugins/StoreForwardPlugin.cpp @@ -6,6 +6,10 @@ #include "configuration.h" #include +#include + + + StoreForwardPlugin *storeForwardPlugin; StoreForwardPluginRadio *storeForwardPluginRadio; @@ -13,8 +17,6 @@ StoreForwardPlugin::StoreForwardPlugin() : concurrency::OSThread("StoreForwardPl int32_t StoreForwardPlugin::runOnce() { -#if 0 - #ifndef NO_ESP32 /* @@ -22,57 +24,27 @@ int32_t StoreForwardPlugin::runOnce() without having to configure it from the PythonAPI or WebUI. */ - radioConfig.preferences.store_forward_plugin_enabled = 0; - - if (radioConfig.preferences.store_forward_plugin_enabled) { + if (0) { if (firstTime) { - DEBUG_MSG("Initializing Store & Forward Plugin\n"); - /* - */ - // Router - if (radioConfig.preferences.is_router) { - if (ESP.getPsramSize()) { - if (ESP.getFreePsram() <= 1024 * 1024) { - // Do the startup here - - } else { - DEBUG_MSG("Device has less than 1M of PSRAM free. Aborting startup.\n"); - DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n"); - - return (INT32_MAX); - } - - } else { - DEBUG_MSG("Device doesn't have PSRAM.\n"); - DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n"); - - return (INT32_MAX); - } - - // Non-Router - } else { - } - // storeForwardPluginRadio = new StoreForwardPluginRadio(); + storeForwardPluginRadio = new StoreForwardPluginRadio(); firstTime = 0; } else { - // TBD + } - return (1000); + return (10); } else { - DEBUG_MSG("Store & Forward Plugin - Disabled\n"); + DEBUG_MSG("StoreForwardPlugin Disabled\n"); return (INT32_MAX); } #endif -#endif - return (INT32_MAX); } MeshPacket *StoreForwardPluginRadio::allocReply() @@ -82,39 +54,20 @@ MeshPacket *StoreForwardPluginRadio::allocReply() return reply; } - void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies) { -#if 0 MeshPacket *p = allocReply(); p->to = dest; p->decoded.want_response = wantReplies; service.sendToMesh(p); -#endif } bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp) { - -#if 0 #ifndef NO_ESP32 - if (radioConfig.preferences.store_forward_plugin_enabled) { - // auto &p = mp.decoded.data; - - if (mp.from != nodeDB.getNodeNum()) { - DEBUG_MSG("Store & Forward Plugin -- Print Start ---------- ---------- ---------- ---------- ----------\n"); - printPacket("PACKET FROM RADIO", &mp); - DEBUG_MSG("Store & Forward Plugin -- Print End ---------- ---------- ---------- ---------- ----------\n"); - } - - } else { - DEBUG_MSG("Store & Forward Plugin - Disabled\n"); - } - -#endif #endif return true; // Let others look at this message also if they want diff --git a/src/plugins/StoreForwardPlugin.h b/src/plugins/StoreForwardPlugin.h index f40c7aa41..1a27222f4 100644 --- a/src/plugins/StoreForwardPlugin.h +++ b/src/plugins/StoreForwardPlugin.h @@ -19,17 +19,13 @@ class StoreForwardPlugin : private concurrency::OSThread extern StoreForwardPlugin *storeForwardPlugin; -/* - * Radio interface for StoreForwardPlugin - * - */ class StoreForwardPluginRadio : public SinglePortPlugin { - //uint32_t lastRxID; + uint32_t lastRxID; public: - StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_STORE_FORWARD_APP) {} - //StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_TEXT_MESSAGE_APP) {} + + StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_TEXT_MESSAGE_APP) {} /** * Send our payload into the mesh @@ -39,8 +35,6 @@ class StoreForwardPluginRadio : public SinglePortPlugin protected: virtual MeshPacket *allocReply(); - //virtual bool wantPortnum(PortNum p){return true;}; - /** Called to handle a particular incoming message @return true if you've guaranteed you've handled this message and no other handlers should be considered for it