update to range test plugin

1.2-legacy
Jm 2021-02-03 08:10:13 -08:00
rodzic 0c71de4e59
commit f46059ec4c
2 zmienionych plików z 42 dodań i 17 usunięć

Wyświetl plik

@ -31,7 +31,7 @@ void setupPlugins()
*/
new SerialPlugin();
new ExternalNotificationPlugin();
new StoreForwardPlugin();
new RangeTestPlugin();
//new StoreForwardPlugin();
rangeTestPlugin = new RangeTestPlugin();
#endif
}

Wyświetl plik

@ -12,15 +12,17 @@
//#undef str
#define RANGETESTPLUGIN_ENABLED 1
#define RANGETESTPLUGIN_SENDER 20000
//#define RANGETESTPLUGIN_SENDER 60 * 1000
#define RANGETESTPLUGIN_SENDER 0
RangeTestPlugin *rangeTestPlugin;
RangeTestPluginRadio *rangeTestPluginRadio;
RangeTestPlugin::RangeTestPlugin() : concurrency::OSThread("RangeTestPlugin") {}
uint16_t packetSequence = 0;
// char serialStringChar[Constants_DATA_PAYLOAD_LEN];
int32_t RangeTestPlugin::runOnce()
@ -32,34 +34,40 @@ int32_t RangeTestPlugin::runOnce()
if (firstTime) {
// Interface with the serial peripheral from in here.
DEBUG_MSG("Initializing Range Test Plugin\n");
rangeTestPluginRadio = new RangeTestPluginRadio();
firstTime = 0;
if (RANGETESTPLUGIN_SENDER) {
DEBUG_MSG("Initializing Range Test Plugin -- Sender\n");
return (RANGETESTPLUGIN_SENDER);
} else {
DEBUG_MSG("Initializing Range Test Plugin -- Receiver\n");
return (500);
}
} else {
// If sender
if (RANGETESTPLUGIN_SENDER) {
return (RANGETESTPLUGIN_SENDER);
// Otherwise, we're a receiver.
} else {
// If sender
DEBUG_MSG("Range Test Plugin - Sending heartbeat\n");
rangeTestPluginRadio->sendPayload();
return (500);
return (RANGETESTPLUGIN_SENDER);
} else {
// Otherwise, we're a receiver.
return (INT32_MAX);
}
// TBD
}
} else {
DEBUG_MSG("Range Test Plugin - Disabled\n");
return (INT32_MAX);
}
return (INT32_MAX);
#endif
}
@ -79,9 +87,10 @@ void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
p->want_ack = true;
uint16_t packetSequence = 123456;
packetSequence++;
static char heartbeatString[20];
snprintf(heartbeatString, sizeof(heartbeatString), "Seq: %d%%", packetSequence);
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);
@ -103,7 +112,10 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp)
// DEBUG_MSG("* * Message came from the mesh\n");
// Serial2.println("* * Message came from the mesh");
Serial2.printf("%s", p.payload.bytes);
//Serial2.printf("%s", p.payload.bytes);
/*
p.payload.size;
gpsStatus->getLatitude();
gpsStatus->getLongitude();
@ -113,6 +125,19 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp)
mp.hop_limit;
mp.decoded.position.latitude_i;
mp.decoded.position.longitude_i;
*/
DEBUG_MSG("p.payload.bytes \"%s\"\n", p.payload.bytes);
DEBUG_MSG("p.payload.size %d\n", p.payload.size);
DEBUG_MSG("mp.rx_snr %f\n", mp.rx_snr);
DEBUG_MSG("mp.hop_limit %d\n", mp.hop_limit);
DEBUG_MSG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i);
DEBUG_MSG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i);
DEBUG_MSG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
DEBUG_MSG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
}
} else {