mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-01 11:42:45 +00:00
update to range test plugin
This commit is contained in:
parent
0c71de4e59
commit
f46059ec4c
@ -31,7 +31,7 @@ void setupPlugins()
|
|||||||
*/
|
*/
|
||||||
new SerialPlugin();
|
new SerialPlugin();
|
||||||
new ExternalNotificationPlugin();
|
new ExternalNotificationPlugin();
|
||||||
new StoreForwardPlugin();
|
//new StoreForwardPlugin();
|
||||||
new RangeTestPlugin();
|
rangeTestPlugin = new RangeTestPlugin();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
@ -12,15 +12,17 @@
|
|||||||
|
|
||||||
//#undef str
|
//#undef str
|
||||||
|
|
||||||
|
|
||||||
#define RANGETESTPLUGIN_ENABLED 1
|
#define RANGETESTPLUGIN_ENABLED 1
|
||||||
#define RANGETESTPLUGIN_SENDER 20000
|
//#define RANGETESTPLUGIN_SENDER 60 * 1000
|
||||||
|
#define RANGETESTPLUGIN_SENDER 0
|
||||||
|
|
||||||
RangeTestPlugin *rangeTestPlugin;
|
RangeTestPlugin *rangeTestPlugin;
|
||||||
RangeTestPluginRadio *rangeTestPluginRadio;
|
RangeTestPluginRadio *rangeTestPluginRadio;
|
||||||
|
|
||||||
RangeTestPlugin::RangeTestPlugin() : concurrency::OSThread("RangeTestPlugin") {}
|
RangeTestPlugin::RangeTestPlugin() : concurrency::OSThread("RangeTestPlugin") {}
|
||||||
|
|
||||||
|
uint16_t packetSequence = 0;
|
||||||
|
|
||||||
// char serialStringChar[Constants_DATA_PAYLOAD_LEN];
|
// char serialStringChar[Constants_DATA_PAYLOAD_LEN];
|
||||||
|
|
||||||
int32_t RangeTestPlugin::runOnce()
|
int32_t RangeTestPlugin::runOnce()
|
||||||
@ -32,34 +34,40 @@ int32_t RangeTestPlugin::runOnce()
|
|||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
|
|
||||||
// Interface with the serial peripheral from in here.
|
// Interface with the serial peripheral from in here.
|
||||||
DEBUG_MSG("Initializing Range Test Plugin\n");
|
|
||||||
|
|
||||||
rangeTestPluginRadio = new RangeTestPluginRadio();
|
rangeTestPluginRadio = new RangeTestPluginRadio();
|
||||||
|
|
||||||
firstTime = 0;
|
firstTime = 0;
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// If sender
|
|
||||||
if (RANGETESTPLUGIN_SENDER) {
|
if (RANGETESTPLUGIN_SENDER) {
|
||||||
|
DEBUG_MSG("Initializing Range Test Plugin -- Sender\n");
|
||||||
return (RANGETESTPLUGIN_SENDER);
|
return (RANGETESTPLUGIN_SENDER);
|
||||||
|
|
||||||
// Otherwise, we're a receiver.
|
|
||||||
} else {
|
} else {
|
||||||
|
DEBUG_MSG("Initializing Range Test Plugin -- Receiver\n");
|
||||||
|
return (500);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (RANGETESTPLUGIN_SENDER) {
|
||||||
|
// If sender
|
||||||
|
DEBUG_MSG("Range Test Plugin - Sending heartbeat\n");
|
||||||
|
|
||||||
rangeTestPluginRadio->sendPayload();
|
rangeTestPluginRadio->sendPayload();
|
||||||
return (500);
|
return (RANGETESTPLUGIN_SENDER);
|
||||||
|
} else {
|
||||||
|
// Otherwise, we're a receiver.
|
||||||
|
|
||||||
|
return (INT32_MAX);
|
||||||
}
|
}
|
||||||
// TBD
|
// TBD
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Range Test Plugin - Disabled\n");
|
DEBUG_MSG("Range Test Plugin - Disabled\n");
|
||||||
|
|
||||||
return (INT32_MAX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (INT32_MAX);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,9 +87,10 @@ void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
|||||||
|
|
||||||
p->want_ack = true;
|
p->want_ack = true;
|
||||||
|
|
||||||
uint16_t packetSequence = 123456;
|
packetSequence++;
|
||||||
|
|
||||||
static char heartbeatString[20];
|
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
|
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);
|
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");
|
// DEBUG_MSG("* * Message came from the mesh\n");
|
||||||
// Serial2.println("* * Message came from the mesh");
|
// Serial2.println("* * Message came from the mesh");
|
||||||
Serial2.printf("%s", p.payload.bytes);
|
//Serial2.printf("%s", p.payload.bytes);
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
p.payload.size;
|
p.payload.size;
|
||||||
gpsStatus->getLatitude();
|
gpsStatus->getLatitude();
|
||||||
gpsStatus->getLongitude();
|
gpsStatus->getLongitude();
|
||||||
@ -113,6 +125,19 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp)
|
|||||||
mp.hop_limit;
|
mp.hop_limit;
|
||||||
mp.decoded.position.latitude_i;
|
mp.decoded.position.latitude_i;
|
||||||
mp.decoded.position.longitude_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 {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user