mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-23 00:58:14 +00:00
Add missing traceroute fields to serialized JSON output (#6087)
This commit is contained in:
parent
3b0232de1b
commit
c67aa25d19
@ -221,6 +221,10 @@ std::string MeshPacketSerializer::JsonSerialize(const meshtastic_MeshPacket *mp,
|
|||||||
&scratch)) {
|
&scratch)) {
|
||||||
decoded = &scratch;
|
decoded = &scratch;
|
||||||
JSONArray route; // Route this message took
|
JSONArray route; // Route this message took
|
||||||
|
JSONArray routeBack; // Route this message took back
|
||||||
|
JSONArray snrTowards; // Snr for forward route
|
||||||
|
JSONArray snrBack; // Snr for reverse route
|
||||||
|
|
||||||
// Lambda function for adding a long name to the route
|
// Lambda function for adding a long name to the route
|
||||||
auto addToRoute = [](JSONArray *route, NodeNum num) {
|
auto addToRoute = [](JSONArray *route, NodeNum num) {
|
||||||
char long_name[40] = "Unknown";
|
char long_name[40] = "Unknown";
|
||||||
@ -236,7 +240,24 @@ std::string MeshPacketSerializer::JsonSerialize(const meshtastic_MeshPacket *mp,
|
|||||||
}
|
}
|
||||||
addToRoute(&route, mp->from); // Ended at the original destination (source of response)
|
addToRoute(&route, mp->from); // Ended at the original destination (source of response)
|
||||||
|
|
||||||
|
addToRoute(&routeBack, mp->from); // Started at the original destination (source of response)
|
||||||
|
for (uint8_t i = 0; i < decoded->route_back_count; i++) {
|
||||||
|
addToRoute(&routeBack, decoded->route_back[i]);
|
||||||
|
}
|
||||||
|
addToRoute(&routeBack, mp->to); // Ended at the original transmitter (destination of response)
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < decoded->snr_back_count; i++) {
|
||||||
|
snrBack.push_back(new JSONValue((float)decoded->snr_back[i] / 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < decoded->snr_towards_count; i++) {
|
||||||
|
snrTowards.push_back(new JSONValue((float)decoded->snr_towards[i] / 4));
|
||||||
|
}
|
||||||
|
|
||||||
msgPayload["route"] = new JSONValue(route);
|
msgPayload["route"] = new JSONValue(route);
|
||||||
|
msgPayload["route_back"] = new JSONValue(routeBack);
|
||||||
|
msgPayload["snr_back"] = new JSONValue(snrBack);
|
||||||
|
msgPayload["snr_towards"] = new JSONValue(snrTowards);
|
||||||
jsonObj["payload"] = new JSONValue(msgPayload);
|
jsonObj["payload"] = new JSONValue(msgPayload);
|
||||||
} else if (shouldLog) {
|
} else if (shouldLog) {
|
||||||
LOG_ERROR(errStr, msgType.c_str());
|
LOG_ERROR(errStr, msgType.c_str());
|
||||||
|
Loading…
Reference in New Issue
Block a user