2021-01-31 17:12:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "SinglePortPlugin.h"
|
|
|
|
#include "concurrency/OSThread.h"
|
|
|
|
#include "configuration.h"
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <functional>
|
|
|
|
|
2021-02-22 04:15:31 +00:00
|
|
|
struct PacketHistoryStruct {
|
|
|
|
uint32_t time;
|
|
|
|
uint32_t to;
|
2021-02-25 04:27:21 +00:00
|
|
|
bool ack;
|
2021-02-22 04:15:31 +00:00
|
|
|
uint8_t bytes[MAX_RHPACKETLEN];
|
|
|
|
};
|
|
|
|
|
2021-03-18 04:03:11 +00:00
|
|
|
class StoreForwardPlugin : public SinglePortPlugin, private concurrency::OSThread
|
2021-01-31 17:12:01 +00:00
|
|
|
{
|
|
|
|
bool firstTime = 1;
|
|
|
|
|
2021-02-17 01:42:46 +00:00
|
|
|
uint32_t receivedRecord[50][2] = {{0}};
|
|
|
|
|
2021-02-23 04:07:19 +00:00
|
|
|
PacketHistoryStruct *packetHistory;
|
2021-02-25 04:27:21 +00:00
|
|
|
uint32_t packetHistoryCurrent = 0;
|
2021-02-23 04:07:19 +00:00
|
|
|
|
2021-01-31 17:12:01 +00:00
|
|
|
public:
|
|
|
|
StoreForwardPlugin();
|
|
|
|
|
2021-02-17 01:42:46 +00:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
2021-03-22 02:45:35 +00:00
|
|
|
void sawNode(uint32_t whoWeSaw, uint32_t sawSecAgo);
|
2021-02-25 04:27:21 +00:00
|
|
|
void historyAdd(const MeshPacket *mp);
|
|
|
|
void historyReport();
|
|
|
|
void historySend(uint32_t msAgo, uint32_t to);
|
2021-02-23 04:07:19 +00:00
|
|
|
void populatePSRAM();
|
2021-02-17 01:42:46 +00:00
|
|
|
|
2021-03-18 04:03:11 +00:00
|
|
|
/**
|
|
|
|
* Send our payload into the mesh
|
|
|
|
*/
|
|
|
|
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
|
2021-03-22 02:45:35 +00:00
|
|
|
void sendPayloadWelcome(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
|
2021-03-18 04:03:11 +00:00
|
|
|
virtual MeshPacket *allocReply();
|
|
|
|
virtual bool wantPortnum(PortNum p) { return true; };
|
|
|
|
|
2021-02-17 01:42:46 +00:00
|
|
|
private:
|
2021-02-22 04:15:31 +00:00
|
|
|
// Nothing here
|
2021-02-17 01:42:46 +00:00
|
|
|
|
2021-01-31 17:12:01 +00:00
|
|
|
protected:
|
|
|
|
virtual int32_t runOnce();
|
2021-03-18 04:03:11 +00:00
|
|
|
|
|
|
|
/** Called to handle a particular incoming message
|
|
|
|
|
2021-09-23 01:42:09 +00:00
|
|
|
@return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for it
|
2021-03-18 04:03:11 +00:00
|
|
|
*/
|
2021-09-23 01:42:09 +00:00
|
|
|
virtual ProcessMessage handleReceived(const MeshPacket &mp);
|
2021-01-31 17:12:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern StoreForwardPlugin *storeForwardPlugin;
|
|
|
|
|
2021-02-15 04:13:52 +00:00
|
|
|
/*
|
|
|
|
* Radio interface for StoreForwardPlugin
|
|
|
|
*
|
|
|
|
*/
|
2021-03-18 04:03:11 +00:00
|
|
|
|
|
|
|
/*
|
2021-01-31 17:12:01 +00:00
|
|
|
class StoreForwardPluginRadio : public SinglePortPlugin
|
|
|
|
{
|
2021-02-17 01:42:46 +00:00
|
|
|
// uint32_t lastRxID;
|
2021-01-31 17:12:01 +00:00
|
|
|
|
|
|
|
public:
|
2021-02-15 04:13:52 +00:00
|
|
|
StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_STORE_FORWARD_APP) {}
|
2021-02-17 01:42:46 +00:00
|
|
|
// StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
|
2021-01-31 17:12:01 +00:00
|
|
|
|
2021-02-28 06:34:53 +00:00
|
|
|
void sendPayloadHeartbeat(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
|
|
|
|
|
2021-01-31 17:12:01 +00:00
|
|
|
protected:
|
2021-03-18 04:03:11 +00:00
|
|
|
virtual MeshPacket *allocReply2();
|
2021-01-31 17:12:01 +00:00
|
|
|
};
|
|
|
|
|
2021-02-15 04:13:52 +00:00
|
|
|
extern StoreForwardPluginRadio *storeForwardPluginRadio;
|
2021-03-18 04:03:11 +00:00
|
|
|
*/
|