From 52d85c9a41819fc3edbb5825a44664ac8cc86da3 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 27 Feb 2021 22:34:53 -0800 Subject: [PATCH] Partial work from laptop -- non-routers can send a heartbeat --- src/plugins/esp32/StoreForwardPlugin.cpp | 20 +++++++++++++++----- src/plugins/esp32/StoreForwardPlugin.h | 5 +++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/plugins/esp32/StoreForwardPlugin.cpp b/src/plugins/esp32/StoreForwardPlugin.cpp index 0550b7af..031f32b4 100644 --- a/src/plugins/esp32/StoreForwardPlugin.cpp +++ b/src/plugins/esp32/StoreForwardPlugin.cpp @@ -66,12 +66,13 @@ int32_t StoreForwardPlugin::runOnce() } } else { - DEBUG_MSG("Initializing Store & Forward Plugin - Enabled but is_router is not turned on.\n"); - DEBUG_MSG( - "Initializing Store & Forward Plugin - If you want to use this plugin, you must also turn on is_router.\n"); - // Non-Router + /* + * If the plugin is turned on and is_router is not enabled, then we'll send a heartbeat every + * few minutes. + */ + storeForwardPluginRadio->sendPayloadHeartbeat(); - return (30 * 1000); + return (3 * 60 * 1000); } } else { @@ -235,6 +236,15 @@ void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies) service.sendToMesh(p); } +void StoreForwardPluginRadio::sendPayloadHeartbeat(NodeNum dest, bool wantReplies) +{ + MeshPacket *p = allocReply(); + p->to = dest; + p->decoded.want_response = wantReplies; + + service.sendToMesh(p); +} + bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 diff --git a/src/plugins/esp32/StoreForwardPlugin.h b/src/plugins/esp32/StoreForwardPlugin.h index e49b38fe..d2a2879c 100644 --- a/src/plugins/esp32/StoreForwardPlugin.h +++ b/src/plugins/esp32/StoreForwardPlugin.h @@ -63,6 +63,11 @@ class StoreForwardPluginRadio : public SinglePortPlugin */ void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + /** + * Send our payload into the mesh + */ + void sendPayloadHeartbeat(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + protected: virtual MeshPacket *allocReply();