mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-29 02:51:17 +00:00
Updating range test and storeforward.
This commit is contained in:
parent
2e8867eda6
commit
937955b36d
@ -65,9 +65,9 @@ Structure of received messages:
|
|||||||
|
|
||||||
Structure of nodes and last time we heard from them. This is a record of any packet type.
|
Structure of nodes and last time we heard from them. This is a record of any packet type.
|
||||||
|
|
||||||
senderRecord
|
receivedRecord
|
||||||
From
|
From
|
||||||
rxTimeMsec
|
rxTimeMillis
|
||||||
|
|
||||||
# General Operation for UC1 - automagically forward packets to a client that may have missed packets
|
# General Operation for UC1 - automagically forward packets to a client that may have missed packets
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
StoreForwardPlugin *storeForwardPlugin;
|
StoreForwardPlugin *storeForwardPlugin;
|
||||||
StoreForwardPluginRadio *storeForwardPluginRadio;
|
StoreForwardPluginRadio *storeForwardPluginRadio;
|
||||||
@ -21,8 +22,8 @@ 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;
|
// radioConfig.preferences.store_forward_plugin_enabled = 1;
|
||||||
radioConfig.preferences.is_router = 0;
|
// radioConfig.preferences.is_router = 1;
|
||||||
|
|
||||||
if (radioConfig.preferences.store_forward_plugin_enabled) {
|
if (radioConfig.preferences.store_forward_plugin_enabled) {
|
||||||
|
|
||||||
@ -60,13 +61,16 @@ int32_t StoreForwardPlugin::runOnce()
|
|||||||
DEBUG_MSG(
|
DEBUG_MSG(
|
||||||
"Initializing Store & Forward Plugin - If you want to use this plugin, you must also turn on is_router.\n");
|
"Initializing Store & Forward Plugin - If you want to use this plugin, you must also turn on is_router.\n");
|
||||||
// Non-Router
|
// Non-Router
|
||||||
|
|
||||||
|
return (30 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// TBD
|
// What do we do if it's not our first time?
|
||||||
|
|
||||||
|
// Maybe some cleanup functions?
|
||||||
}
|
}
|
||||||
|
|
||||||
return (1000);
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Store & Forward Plugin - Disabled\n");
|
DEBUG_MSG("Store & Forward Plugin - Disabled\n");
|
||||||
|
|
||||||
@ -77,6 +81,43 @@ int32_t StoreForwardPlugin::runOnce()
|
|||||||
return (INT32_MAX);
|
return (INT32_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We saw a node.
|
||||||
|
uint32_t StoreForwardPlugin::sawNode(uint32_t node)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: Move receivedRecord into the PSRAM
|
||||||
|
|
||||||
|
TODO: Gracefully handle the case where we run out of records.
|
||||||
|
Maybe replace the oldest record that hasn't been seen in a while and assume they won't be back.
|
||||||
|
|
||||||
|
TODO: Implment this as a std::map for quicker lookups (maybe it doesn't matter?).
|
||||||
|
*/
|
||||||
|
|
||||||
|
DEBUG_MSG("looking for node - %i\n", node);
|
||||||
|
for (int i = 0; i < 50; i++) {
|
||||||
|
DEBUG_MSG("Iterating through the seen nodes - %d %d %d\n", i, receivedRecord[i][0], receivedRecord[i][1]);
|
||||||
|
// First time seeing that node.
|
||||||
|
if (receivedRecord[i][0] == 0) {
|
||||||
|
DEBUG_MSG("New node! Woohoo! Win!\n");
|
||||||
|
receivedRecord[i][0] = node;
|
||||||
|
receivedRecord[i][1] = millis();
|
||||||
|
|
||||||
|
return receivedRecord[i][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// We've seen this node before.
|
||||||
|
if (receivedRecord[i][0] == node) {
|
||||||
|
DEBUG_MSG("We've seen this node before\n");
|
||||||
|
uint32_t lastSaw = receivedRecord[i][1];
|
||||||
|
receivedRecord[i][1] = millis();
|
||||||
|
return lastSaw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
MeshPacket *StoreForwardPluginRadio::allocReply()
|
MeshPacket *StoreForwardPluginRadio::allocReply()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -101,9 +142,11 @@ bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp)
|
|||||||
// auto &p = mp.decoded.data;
|
// auto &p = mp.decoded.data;
|
||||||
|
|
||||||
if (mp.from != nodeDB.getNodeNum()) {
|
if (mp.from != nodeDB.getNodeNum()) {
|
||||||
DEBUG_MSG("Store & Forward Plugin -- Print Start ---------- ---------- ---------- ---------- ----------\n");
|
DEBUG_MSG("Store & Forward Plugin -- Print Start ---------- ---------- ---------- ---------- ----------\n\n\n");
|
||||||
printPacket("----- PACKET FROM RADIO", &mp);
|
printPacket("----- PACKET FROM RADIO", &mp);
|
||||||
DEBUG_MSG("Store & Forward Plugin -- Print End ---------- ---------- ---------- ---------- ----------\n");
|
// DEBUG_MSG("\n\nStore & Forward Plugin -- Print End ---------- ---------- ---------- ---------- ----------\n");
|
||||||
|
uint32_t sawTime = storeForwardPlugin->sawNode(mp.from);
|
||||||
|
DEBUG_MSG("Last Saw this node %d, %d millis ago\n", mp.from, (millis() - sawTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -10,9 +10,22 @@ class StoreForwardPlugin : private concurrency::OSThread
|
|||||||
{
|
{
|
||||||
bool firstTime = 1;
|
bool firstTime = 1;
|
||||||
|
|
||||||
|
// TODO: Move this into the PSRAM
|
||||||
|
// TODO: Allow configuration of the maximum number of records.
|
||||||
|
uint32_t receivedRecord[50][2] = {{0}};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StoreForwardPlugin();
|
StoreForwardPlugin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Update our local reference of when we last saw that node.
|
||||||
|
@return 0 if we have never seen that node before otherwise return the last time we saw the node.
|
||||||
|
*/
|
||||||
|
uint32_t sawNode(uint32_t);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Nothing here
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int32_t runOnce();
|
virtual int32_t runOnce();
|
||||||
};
|
};
|
||||||
@ -49,4 +62,3 @@ class StoreForwardPluginRadio : public SinglePortPlugin
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern StoreForwardPluginRadio *storeForwardPluginRadio;
|
extern StoreForwardPluginRadio *storeForwardPluginRadio;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user