mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-13 16:55:08 +00:00
Store Forward can see All(?) rx packets!
This commit is contained in:
parent
2472d6fd1b
commit
e6605e5ac8
@ -33,9 +33,9 @@ void setupPlugins()
|
|||||||
new ExternalNotificationPlugin();
|
new ExternalNotificationPlugin();
|
||||||
|
|
||||||
//rangeTestPlugin = new RangeTestPlugin();
|
//rangeTestPlugin = new RangeTestPlugin();
|
||||||
//storeForwardPlugin = new StoreForwardPlugin();
|
storeForwardPlugin = new StoreForwardPlugin();
|
||||||
|
|
||||||
new RangeTestPlugin();
|
new RangeTestPlugin();
|
||||||
new StoreForwardPlugin();
|
//new StoreForwardPlugin();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
@ -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
|
|
@ -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
|
|
@ -6,10 +6,6 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StoreForwardPlugin *storeForwardPlugin;
|
StoreForwardPlugin *storeForwardPlugin;
|
||||||
StoreForwardPluginRadio *storeForwardPluginRadio;
|
StoreForwardPluginRadio *storeForwardPluginRadio;
|
||||||
|
|
||||||
@ -17,6 +13,7 @@ StoreForwardPlugin::StoreForwardPlugin() : concurrency::OSThread("StoreForwardPl
|
|||||||
|
|
||||||
int32_t StoreForwardPlugin::runOnce()
|
int32_t StoreForwardPlugin::runOnce()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -24,27 +21,60 @@ int32_t StoreForwardPlugin::runOnce()
|
|||||||
without having to configure it from the PythonAPI or WebUI.
|
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) {
|
if (firstTime) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
storeForwardPluginRadio = new StoreForwardPluginRadio();
|
||||||
|
|
||||||
firstTime = 0;
|
firstTime = 0;
|
||||||
|
|
||||||
} else {
|
} 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (10);
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("StoreForwardPlugin Disabled\n");
|
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 (1000);
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("Store & Forward Plugin - Disabled\n");
|
||||||
|
|
||||||
return (INT32_MAX);
|
return (INT32_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
return (INT32_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshPacket *StoreForwardPluginRadio::allocReply()
|
MeshPacket *StoreForwardPluginRadio::allocReply()
|
||||||
@ -54,6 +84,7 @@ MeshPacket *StoreForwardPluginRadio::allocReply()
|
|||||||
|
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
||||||
{
|
{
|
||||||
MeshPacket *p = allocReply();
|
MeshPacket *p = allocReply();
|
||||||
@ -66,7 +97,18 @@ void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
|||||||
bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp)
|
bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp)
|
||||||
{
|
{
|
||||||
#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
|
||||||
|
|
||||||
|
@ -19,13 +19,17 @@ 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
|
||||||
@ -35,6 +39,8 @@ 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
|
||||||
@ -43,3 +49,4 @@ class StoreForwardPluginRadio : public SinglePortPlugin
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern StoreForwardPluginRadio *storeForwardPluginRadio;
|
extern StoreForwardPluginRadio *storeForwardPluginRadio;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user