From c00173dbd2d09a73e63eba1042bead70aafa63f8 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 31 Jan 2021 18:20:08 -0800 Subject: [PATCH] partial work --- src/plugins/RangeTestPlugin.cpp | 34 +++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/plugins/RangeTestPlugin.cpp b/src/plugins/RangeTestPlugin.cpp index 1b8f80f3..ffe98458 100644 --- a/src/plugins/RangeTestPlugin.cpp +++ b/src/plugins/RangeTestPlugin.cpp @@ -5,11 +5,16 @@ #include "Router.h" #include "configuration.h" #include - #include +//#include +//#include +//#include + +//#undef str + #define RANGETESTPLUGIN_ENABLED 1 -#define RANGETESTPLUGIN_SENDER 0 +#define RANGETESTPLUGIN_SENDER 20000 RangeTestPlugin *rangeTestPlugin; RangeTestPluginRadio *rangeTestPluginRadio; @@ -34,10 +39,21 @@ int32_t RangeTestPlugin::runOnce() firstTime = 0; } else { + + // If sender + if (RANGETESTPLUGIN_SENDER) { + + return (RANGETESTPLUGIN_SENDER); + + // Otherwise, we're a receiver. + } else { + + rangeTestPluginRadio->sendPayload(); + return (500); + } // TBD } - return (10); } else { DEBUG_MSG("Range Test Plugin - Disabled\n"); @@ -61,6 +77,15 @@ void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies) p->to = dest; p->decoded.want_response = wantReplies; + p->want_ack = true; + + uint16_t packetSequence = 123456; + static char heartbeatString[20]; + snprintf(heartbeatString, sizeof(heartbeatString), "Seq: %d%%", packetSequence); + + p->decoded.data.payload.size = strlen(heartbeatString); // You must specify how many bytes are in the reply + memcpy(p->decoded.data.payload.bytes, heartbeatString, p->decoded.data.payload.size); + service.sendToMesh(p); } @@ -88,9 +113,6 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp) mp.hop_limit; mp.decoded.position.latitude_i; mp.decoded.position.longitude_i; - - - } } else {