#668 Partial work for store & forward

This commit is contained in:
Jm Casler 2021-02-14 08:44:49 -08:00
parent 36643cf5f5
commit 3201d1c3bc
2 changed files with 15 additions and 42 deletions

View File

@ -11,14 +11,6 @@
#define STORE_RECORDS 5000
#define BYTES_PER_RECORDS 512
struct sfRecord
{
uint8_t bytes[BYTES_PER_RECORDS];
uint32_t timestamp; // Time the packet was received
};
struct sfRecord records[STORE_RECORDS];
#define STOREFORWARDPLUGIN_ENABLED 0
StoreForwardPlugin *storeForwardPlugin;
@ -69,7 +61,6 @@ int32_t StoreForwardPlugin::runOnce()
// Non-Router
} else {
}
storeForwardPluginRadio = new StoreForwardPluginRadio();
@ -118,36 +109,15 @@ bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp)
if (STOREFORWARDPLUGIN_ENABLED) {
auto &p = mp.decoded.data;
// DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n",
// nodeDB.getNodeNum(), mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes);
// auto &p = mp.decoded.data;
if (mp.from == nodeDB.getNodeNum()) {
/*
* If radioConfig.preferences.serialplugin_echo is true, then echo the packets that are sent out back to the TX
* of the serial interface.
*/
if (radioConfig.preferences.serialplugin_echo) {
// For some reason, we get the packet back twice when we send out of the radio.
// TODO: need to find out why.
if (lastRxID != mp.id) {
lastRxID = mp.id;
// DEBUG_MSG("* * Message came this device\n");
// Serial2.println("* * Message came this device");
Serial2.printf("%s", p.payload.bytes);
}
if (mp.from != nodeDB.getNodeNum()) {
DEBUG_MSG("Store & Forward Plugin ---------- ---------- ---------- ---------- ----------\n");
printPacket("PACKET FROM PHONE", &mp);
}
} else {
// DEBUG_MSG("* * Message came from the mesh\n");
// Serial2.println("* * Message came from the mesh");
Serial2.printf("%s", p.payload.bytes);
}
} else {
DEBUG_MSG("Serial Plugin Disabled\n");
DEBUG_MSG("Store & Forward Plugin - Disabled\n");
}
#endif

View File

@ -34,6 +34,7 @@ class StoreForwardPluginRadio : public SinglePortPlugin
*/
// SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
// SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_STORE_FORWARD_APP) {}
StoreForwardPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP) {}
/**
@ -44,6 +45,8 @@ class StoreForwardPluginRadio : public SinglePortPlugin
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