Store Forward can see All(?) rx packets!

1.2-legacy
Jm 2021-02-14 20:13:52 -08:00
rodzic 2472d6fd1b
commit e6605e5ac8
5 zmienionych plików z 65 dodań i 196 usunięć

Wyświetl plik

@ -33,9 +33,9 @@ void setupPlugins()
new ExternalNotificationPlugin();
//rangeTestPlugin = new RangeTestPlugin();
//storeForwardPlugin = new StoreForwardPlugin();
storeForwardPlugin = new StoreForwardPlugin();
new RangeTestPlugin();
new StoreForwardPlugin();
//new StoreForwardPlugin();
#endif
}

Wyświetl plik

@ -1,125 +0,0 @@
#if 0
#include "StoreForwardPlugin.h"
#include "MeshService.h"
#include "NodeDB.h"
#include "RTC.h"
#include "Router.h"
#include "configuration.h"
#include <Arduino.h>
StoreForwardPlugin *storeForwardPlugin;
StoreForwardPluginRadio *storeForwardPluginRadio;
StoreForwardPlugin::StoreForwardPlugin() : concurrency::OSThread("StoreForwardPlugin") {}
int32_t StoreForwardPlugin::runOnce()
{
#if 0
#ifndef NO_ESP32
/*
Uncomment the preferences below if you want to use the plugin
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 (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();
firstTime = 0;
} else {
// TBD
}
return (1000);
} else {
DEBUG_MSG("Store & Forward Plugin - Disabled\n");
return (INT32_MAX);
}
#endif
#endif
return (INT32_MAX);
}
MeshPacket *StoreForwardPluginRadio::allocReply()
{
auto reply = allocDataPacket(); // Allocate a packet for sending
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
}
#endif

Wyświetl plik

@ -1,55 +0,0 @@
#if 0
#pragma once
#include "SinglePortPlugin.h"
#include "concurrency/OSThread.h"
#include "configuration.h"
#include <Arduino.h>
#include <functional>
class StoreForwardPlugin : private concurrency::OSThread
{
bool firstTime = 1;
public:
StoreForwardPlugin();
protected:
virtual int32_t runOnce();
};
extern StoreForwardPlugin *storeForwardPlugin;
/*
* Radio interface for StoreForwardPlugin
*
*/
class StoreForwardPluginRadio : public SinglePortPlugin
{
//uint32_t lastRxID;
public:
StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_STORE_FORWARD_APP) {}
//StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
/**
* Send our payload into the mesh
*/
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
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
*/
virtual bool handleReceived(const MeshPacket &mp);
};
extern StoreForwardPluginRadio *storeForwardPluginRadio;
#endif

Wyświetl plik

@ -6,10 +6,6 @@
#include "configuration.h"
#include <Arduino.h>
#include <assert.h>
StoreForwardPlugin *storeForwardPlugin;
StoreForwardPluginRadio *storeForwardPluginRadio;
@ -17,6 +13,7 @@ StoreForwardPlugin::StoreForwardPlugin() : concurrency::OSThread("StoreForwardPl
int32_t StoreForwardPlugin::runOnce()
{
#ifndef NO_ESP32
/*
@ -24,27 +21,60 @@ int32_t StoreForwardPlugin::runOnce()
without having to configure it from the PythonAPI or WebUI.
*/
if (0) {
radioConfig.preferences.store_forward_plugin_enabled = 1;
radioConfig.preferences.is_router = 0;
if (radioConfig.preferences.store_forward_plugin_enabled) {
if (firstTime) {
/*
*/
storeForwardPluginRadio = new StoreForwardPluginRadio();
if (radioConfig.preferences.is_router) {
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled\n");
// Router
if (ESP.getPsramSize()) {
if (ESP.getFreePsram() >= 1024 * 1024) {
// Do the startup here
storeForwardPluginRadio = new StoreForwardPluginRadio();
firstTime = 0;
firstTime = 0;
} 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);
}
} 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
}
} else {
// TBD
}
return (10);
return (1000);
} else {
DEBUG_MSG("StoreForwardPlugin Disabled\n");
DEBUG_MSG("Store & Forward Plugin - Disabled\n");
return (INT32_MAX);
}
#endif
return (INT32_MAX);
}
MeshPacket *StoreForwardPluginRadio::allocReply()
@ -54,6 +84,7 @@ MeshPacket *StoreForwardPluginRadio::allocReply()
return reply;
}
void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
{
MeshPacket *p = allocReply();
@ -66,7 +97,18 @@ void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp)
{
#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

Wyświetl plik

@ -19,13 +19,17 @@ 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_TEXT_MESSAGE_APP) {}
StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_STORE_FORWARD_APP) {}
//StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
/**
* Send our payload into the mesh
@ -35,6 +39,8 @@ 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
@ -42,4 +48,5 @@ class StoreForwardPluginRadio : public SinglePortPlugin
virtual bool handleReceived(const MeshPacket &mp);
};
extern StoreForwardPluginRadio *storeForwardPluginRadio;
extern StoreForwardPluginRadio *storeForwardPluginRadio;