Framework for storeforward

This commit is contained in:
Jm 2021-02-14 14:01:08 -08:00
parent f1a65f9d0e
commit 24329a26de
3 changed files with 12 additions and 66 deletions

View File

@ -41,7 +41,6 @@ int32_t RangeTestPlugin::runOnce()
// Fixed position is useful when testing indoors. // Fixed position is useful when testing indoors.
// radioConfig.preferences.fixed_position = 1; // radioConfig.preferences.fixed_position = 1;
uint32_t senderHeartbeat = radioConfig.preferences.range_test_plugin_sender * 1000; uint32_t senderHeartbeat = radioConfig.preferences.range_test_plugin_sender * 1000;
if (radioConfig.preferences.range_test_plugin_enabled) { if (radioConfig.preferences.range_test_plugin_enabled) {

View File

@ -6,6 +6,10 @@
#include "configuration.h" #include "configuration.h"
#include <Arduino.h> #include <Arduino.h>
#include <assert.h>
StoreForwardPlugin *storeForwardPlugin; StoreForwardPlugin *storeForwardPlugin;
StoreForwardPluginRadio *storeForwardPluginRadio; StoreForwardPluginRadio *storeForwardPluginRadio;
@ -13,8 +17,6 @@ StoreForwardPlugin::StoreForwardPlugin() : concurrency::OSThread("StoreForwardPl
int32_t StoreForwardPlugin::runOnce() int32_t StoreForwardPlugin::runOnce()
{ {
#if 0
#ifndef NO_ESP32 #ifndef NO_ESP32
/* /*
@ -22,57 +24,27 @@ int32_t StoreForwardPlugin::runOnce()
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
*/ */
radioConfig.preferences.store_forward_plugin_enabled = 0; if (0) {
if (radioConfig.preferences.store_forward_plugin_enabled) {
if (firstTime) { if (firstTime) {
DEBUG_MSG("Initializing Store & Forward Plugin\n");
/*
*/
// Router storeForwardPluginRadio = new StoreForwardPluginRadio();
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();
firstTime = 0; firstTime = 0;
} else { } else {
// TBD
} }
return (1000); return (10);
} else { } else {
DEBUG_MSG("Store & Forward Plugin - Disabled\n"); DEBUG_MSG("StoreForwardPlugin Disabled\n");
return (INT32_MAX); return (INT32_MAX);
} }
#endif #endif
#endif
return (INT32_MAX);
} }
MeshPacket *StoreForwardPluginRadio::allocReply() MeshPacket *StoreForwardPluginRadio::allocReply()
@ -82,39 +54,20 @@ MeshPacket *StoreForwardPluginRadio::allocReply()
return reply; return reply;
} }
void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies) void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
{ {
#if 0
MeshPacket *p = allocReply(); MeshPacket *p = allocReply();
p->to = dest; p->to = dest;
p->decoded.want_response = wantReplies; p->decoded.want_response = wantReplies;
service.sendToMesh(p); service.sendToMesh(p);
#endif
} }
bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp) bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp)
{ {
#if 0
#ifndef NO_ESP32 #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 #endif
return true; // Let others look at this message also if they want return true; // Let others look at this message also if they want

View File

@ -19,17 +19,13 @@ class StoreForwardPlugin : private concurrency::OSThread
extern StoreForwardPlugin *storeForwardPlugin; extern StoreForwardPlugin *storeForwardPlugin;
/*
* Radio interface for StoreForwardPlugin
*
*/
class StoreForwardPluginRadio : public SinglePortPlugin class StoreForwardPluginRadio : public SinglePortPlugin
{ {
//uint32_t lastRxID; uint32_t lastRxID;
public: 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 * Send our payload into the mesh
@ -39,8 +35,6 @@ class StoreForwardPluginRadio : public SinglePortPlugin
protected: protected:
virtual MeshPacket *allocReply(); virtual MeshPacket *allocReply();
//virtual bool wantPortnum(PortNum p){return true;};
/** Called to handle a particular incoming message /** 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 @return true if you've guaranteed you've handled this message and no other handlers should be considered for it