From 871f6854b5751b88fbb3b3905970125f6ffb4285 Mon Sep 17 00:00:00 2001 From: John Gorkos - AB0OO Date: Wed, 12 Jun 2024 08:22:01 -0700 Subject: [PATCH 1/4] feature-mqtt: add hop_start and hop_limit to MQTT uplink --- src/mqtt/MQTT.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 566eb352d..905c2b7d3 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -902,7 +902,9 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) jsonObj["snr"] = new JSONValue((float)mp->rx_snr); if (mp->hop_start != 0 && mp->hop_limit <= mp->hop_start) jsonObj["hops_away"] = new JSONValue((unsigned int)(mp->hop_start - mp->hop_limit)); - + jsonObj["hop_start"] = new JSONValue((unsigned int)(mp->hop_start)); + jsonObj["hop_limit"] = new JSONValue((unsigned int)(mp->hop_limit)); + // serialize and write it to the stream JSONValue *value = new JSONValue(jsonObj); std::string jsonStr = value->Stringify(); From d80bcd7d67df2876b9536cd1418bec64171269e9 Mon Sep 17 00:00:00 2001 From: John Gorkos - AB0OO Date: Wed, 12 Jun 2024 12:59:52 -0700 Subject: [PATCH 2/4] adding only hop_start, per @GUVWAF --- src/mqtt/MQTT.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 905c2b7d3..4f685cd7a 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -903,7 +903,6 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) if (mp->hop_start != 0 && mp->hop_limit <= mp->hop_start) jsonObj["hops_away"] = new JSONValue((unsigned int)(mp->hop_start - mp->hop_limit)); jsonObj["hop_start"] = new JSONValue((unsigned int)(mp->hop_start)); - jsonObj["hop_limit"] = new JSONValue((unsigned int)(mp->hop_limit)); // serialize and write it to the stream JSONValue *value = new JSONValue(jsonObj); From b42185c722c27e17523bf2474079915f8eca7f04 Mon Sep 17 00:00:00 2001 From: John Gorkos - AB0OO Date: Wed, 12 Jun 2024 13:02:01 -0700 Subject: [PATCH 3/4] included hop_start in conditional for hop_away --- src/mqtt/MQTT.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 4f685cd7a..d93166ce9 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -900,9 +900,10 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) jsonObj["rssi"] = new JSONValue((int)mp->rx_rssi); if (mp->rx_snr != 0) jsonObj["snr"] = new JSONValue((float)mp->rx_snr); - if (mp->hop_start != 0 && mp->hop_limit <= mp->hop_start) + if (mp->hop_start != 0 && mp->hop_limit <= mp->hop_start) { jsonObj["hops_away"] = new JSONValue((unsigned int)(mp->hop_start - mp->hop_limit)); - jsonObj["hop_start"] = new JSONValue((unsigned int)(mp->hop_start)); + jsonObj["hop_start"] = new JSONValue((unsigned int)(mp->hop_start)); + } // serialize and write it to the stream JSONValue *value = new JSONValue(jsonObj); From f7433eb4ee772477493545800da88eafc1455e96 Mon Sep 17 00:00:00 2001 From: John Gorkos - AB0OO Date: Wed, 12 Jun 2024 14:36:38 -0700 Subject: [PATCH 4/4] trunk formatting --- src/mqtt/MQTT.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index d93166ce9..9f9ac5c24 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -904,7 +904,7 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) jsonObj["hops_away"] = new JSONValue((unsigned int)(mp->hop_start - mp->hop_limit)); jsonObj["hop_start"] = new JSONValue((unsigned int)(mp->hop_start)); } - + // serialize and write it to the stream JSONValue *value = new JSONValue(jsonObj); std::string jsonStr = value->Stringify();