From 092e6f2424aac486267c15e1c94f18c36093017a Mon Sep 17 00:00:00 2001 From: Tavis Date: Tue, 17 Oct 2023 01:50:36 -1000 Subject: [PATCH] add rssi and snr to json output (#2894) * add rssi and snr to json output * explicitly cast to int and float --- src/mqtt/MQTT.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index cbaba45d6..a9e80c947 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -692,6 +692,10 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) jsonObj["channel"] = new JSONValue((uint)mp->channel); jsonObj["type"] = new JSONValue(msgType.c_str()); jsonObj["sender"] = new JSONValue(owner.id); + if (mp->rx_rssi != 0) + jsonObj["rssi"] = new JSONValue((int)mp->rx_rssi); + if (mp->rx_snr != 0) + jsonObj["snr"] = new JSONValue((float)mp->rx_snr); // serialize and write it to the stream JSONValue *value = new JSONValue(jsonObj);