mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-14 14:31:24 +00:00
Compare commits
No commits in common. "9e430a2821db11cc63dd8d8455519eb41076e69f" and "097dbc1fca8021261fd90d96e3c97bacb3511a4f" have entirely different histories.
9e430a2821
...
097dbc1fca
@ -220,11 +220,7 @@ std::string MeshPacketSerializer::JsonSerialize(const meshtastic_MeshPacket *mp,
|
|||||||
if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &meshtastic_RouteDiscovery_msg,
|
if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &meshtastic_RouteDiscovery_msg,
|
||||||
&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";
|
||||||
@ -240,24 +236,7 @@ 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