refactor(mqtt): reorganize packet message structure in MQTTMessageBuilder

Updated the buildPacketMessage function to improve the structure of the JSON object being built. The 'origin_id' field has been moved to a later position, and the 'hash' field has been added to enhance the packet's metadata. This change aims to streamline the message format for better clarity and consistency.
This commit is contained in:
agessaman committed 2026-04-25 17:02:41 -07:00
1 parent bfcf017625
commit 8be27e4e94
1 file changed
+3 -3
+3 -3
View File
@@ -117,9 +117,9 @@ int MQTTMessageBuilder::buildPacketMessage(
snprintf(snr_str, sizeof(snr_str), "%.1f", snr);
snprintf(rssi_str, sizeof(rssi_str), "%d", rssi);
root["origin"] = origin;
root["origin_id"] = origin_id;
root["timestamp"] = timestamp;
root["origin"] = origin;
root["hash"] = hash;
root["type"] = "PACKET";
root["direction"] = direction;
root["time"] = time;
@@ -129,12 +129,12 @@ int MQTTMessageBuilder::buildPacketMessage(
root["route"] = route;
root["payload_len"] = payload_len_str;
root["raw"] = raw;
root["origin_id"] = origin_id;
// SNR and RSSI are only meaningful for RX packets (received from radio)
if (strcmp(direction, "rx") == 0) {
root["SNR"] = snr_str;
root["RSSI"] = rssi_str;
}
root["hash"] = hash;
if (path && strlen(path) > 0) {
root["path"] = path;