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>
|
|
|
|
|
|
|
|
class StoreForwardPlugin : private concurrency::OSThread
|
|
|
|
{
|
|
|
|
bool firstTime = 1;
|
|
|
|
|
2021-02-17 01:42:46 +00:00
|
|
|
// TODO: Move this into the PSRAM
|
|
|
|
// TODO: Allow configuration of the maximum number of records.
|
|
|
|
uint32_t receivedRecord[50][2] = {{0}};
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
uint32_t sawNode(uint32_t);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Nothing here
|
|
|
|
|
2021-01-31 17:12:01 +00:00
|
|
|
protected:
|
|
|
|
virtual int32_t runOnce();
|
|
|
|
};
|
|
|
|
|
|
|
|
extern StoreForwardPlugin *storeForwardPlugin;
|
|
|
|
|
2021-02-15 04:13:52 +00:00
|
|
|
/*
|
|
|
|
* Radio interface for StoreForwardPlugin
|
|
|
|
*
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Send our payload into the mesh
|
|
|
|
*/
|
|
|
|
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual MeshPacket *allocReply();
|
|
|
|
|
2021-02-17 01:42:46 +00:00
|
|
|
virtual bool wantPortnum(PortNum p) { return true; };
|
2021-02-15 04:13:52 +00:00
|
|
|
|
2021-01-31 17:12:01 +00:00
|
|
|
/** 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);
|
|
|
|
};
|
|
|
|
|
2021-02-15 04:13:52 +00:00
|
|
|
extern StoreForwardPluginRadio *storeForwardPluginRadio;
|