add rssi and snr to json output (#2894)

* add rssi and snr to json output

* explicitly cast to int and float
This commit is contained in:
Tavis 2023-10-17 01:50:36 -10:00 committed by GitHub
parent e6b20bff77
commit 092e6f2424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);