Update to store and forward. Don't merge this to main!

This commit is contained in:
Jm
2021-02-14 13:31:11 -08:00
parent ae46b3df32
commit f1a65f9d0e
6 changed files with 32 additions and 39 deletions

View File

@@ -6,7 +6,7 @@
#include "configuration.h"
#include <Arduino.h>
#include <assert.h>
//#include <assert.h>
/*

View File

@@ -31,7 +31,11 @@ void setupPlugins()
*/
new SerialPlugin();
new ExternalNotificationPlugin();
//rangeTestPlugin = new RangeTestPlugin();
//storeForwardPlugin = new StoreForwardPlugin();
rangeTestPlugin = new RangeTestPlugin();
new RangeTestPlugin();
new StoreForwardPlugin();
#endif
}

View File

@@ -6,7 +6,7 @@
#include "configuration.h"
#include <Arduino.h>
#include <SPIFFS.h>
#include <assert.h>
//#include <assert.h>
/*
As a sender, I can send packets every n-seonds. These packets include an incramented PacketID.

View File

@@ -6,22 +6,15 @@
#include "configuration.h"
#include <Arduino.h>
#include <assert.h>
#define STORE_RECORDS 5000
#define BYTES_PER_RECORDS 512
#define STOREFORWARDPLUGIN_ENABLED 0
StoreForwardPlugin *storeForwardPlugin;
StoreForwardPluginRadio *storeForwardPluginRadio;
StoreForwardPlugin::StoreForwardPlugin() : concurrency::OSThread("SerialPlugin") {}
// char serialStringChar[Constants_DATA_PAYLOAD_LEN];
StoreForwardPlugin::StoreForwardPlugin() : concurrency::OSThread("StoreForwardPlugin") {}
int32_t StoreForwardPlugin::runOnce()
{
#if 0
#ifndef NO_ESP32
/*
@@ -29,15 +22,15 @@ int32_t StoreForwardPlugin::runOnce()
without having to configure it from the PythonAPI or WebUI.
*/
// radioConfig.preferences.store_forward_plugin_enabled = 1;
// radioConfig.preferences.store_forward_plugin_records = 80;
radioConfig.preferences.store_forward_plugin_enabled = 0;
if (radioConfig.preferences.store_forward_plugin_enabled) {
if (firstTime) {
// Interface with the serial peripheral from in here.
DEBUG_MSG("Initializing Store & Forward Plugin\n");
/*
*/
// Router
if (radioConfig.preferences.is_router) {
@@ -62,8 +55,7 @@ int32_t StoreForwardPlugin::runOnce()
// Non-Router
} else {
}
storeForwardPluginRadio = new StoreForwardPluginRadio();
// storeForwardPluginRadio = new StoreForwardPluginRadio();
firstTime = 0;
@@ -71,7 +63,7 @@ int32_t StoreForwardPlugin::runOnce()
// TBD
}
return (10);
return (1000);
} else {
DEBUG_MSG("Store & Forward Plugin - Disabled\n");
@@ -79,6 +71,8 @@ int32_t StoreForwardPlugin::runOnce()
}
#endif
#endif
return (INT32_MAX);
}
MeshPacket *StoreForwardPluginRadio::allocReply()
@@ -91,35 +85,36 @@ MeshPacket *StoreForwardPluginRadio::allocReply()
void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
{
#if 0
MeshPacket *p = allocReply();
p->to = dest;
p->decoded.want_response = wantReplies;
// p->want_ack = SERIALPLUGIN_ACK;
// p->decoded.data.payload.size = strlen(serialStringChar); // You must specify how many bytes are in the reply
// memcpy(p->decoded.data.payload.bytes, serialStringChar, p->decoded.data.payload.size);
service.sendToMesh(p);
#endif
}
bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp)
{
#if 0
#ifndef NO_ESP32
if (STOREFORWARDPLUGIN_ENABLED) {
if (radioConfig.preferences.store_forward_plugin_enabled) {
// auto &p = mp.decoded.data;
if (mp.from != nodeDB.getNodeNum()) {
DEBUG_MSG("Store & Forward Plugin ---------- ---------- ---------- ---------- ----------\n");
printPacket("PACKET FROM PHONE", &mp);
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

View File

@@ -20,22 +20,16 @@ class StoreForwardPlugin : private concurrency::OSThread
extern StoreForwardPlugin *storeForwardPlugin;
/*
* Radio interface for SerialPlugin
* Radio interface for StoreForwardPlugin
*
*/
class StoreForwardPluginRadio : public SinglePortPlugin
{
uint32_t lastRxID;
//uint32_t lastRxID;
public:
/*
TODO: Switch this to PortNum_SERIAL_APP once the change is able to be merged back here
from the main code.
*/
// SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
// SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_STORE_FORWARD_APP) {}
StoreForwardPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP) {}
StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_STORE_FORWARD_APP) {}
//StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
/**
* Send our payload into the mesh
@@ -45,7 +39,7 @@ class StoreForwardPluginRadio : public SinglePortPlugin
protected:
virtual MeshPacket *allocReply();
virtual bool wantPortnum(PortNum p){return true;};
//virtual bool wantPortnum(PortNum p){return true;};
/** Called to handle a particular incoming message