From 404d0dda79543f39074abe0271afbe568dda83b3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 10 Feb 2024 14:20:04 -0600 Subject: [PATCH] Fix - Add GeoChat To field to payloads and handle compression (#3199) * WIP ATAK plugin message handling * Log * Update size and regen * Rework protos and remove compression * Track * Altitude * Protos * Protos and formatting * Add to column * Fixes / updates * Doh! * S * Refactoring and compression fixes * Fix missing (to) from ATAK geochat * Trunk * Explicitly set has_to * Fmt * Protobufs --- protobufs | 2 +- src/modules/AtakPluginModule.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/protobufs b/protobufs index 1fa72525a1..99bd42baf8 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 1fa72525a13117908a850d6754b5368eabdee163 +Subproject commit 99bd42baf8dd2e8ca0eec70f05e1cf7f1a40a283 diff --git a/src/modules/AtakPluginModule.cpp b/src/modules/AtakPluginModule.cpp index 86e1438118..ffc4fe68ab 100644 --- a/src/modules/AtakPluginModule.cpp +++ b/src/modules/AtakPluginModule.cpp @@ -84,6 +84,15 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast LOG_DEBUG("Uncompressed chat message '%s' - %d bytes\n", t->payload_variant.chat.message, strlen(t->payload_variant.chat.message)); LOG_DEBUG("Compressed chat message '%s' - %d bytes\n", compressed.payload_variant.chat.message, length); + + if (t->payload_variant.chat.has_to) { + compressed.payload_variant.chat.has_to = true; + length = unishox2_compress_simple(t->payload_variant.chat.to, strlen(t->payload_variant.chat.to), + compressed.payload_variant.chat.to); + LOG_DEBUG("Uncompressed chat to '%s' - %d bytes\n", t->payload_variant.chat.to, + strlen(t->payload_variant.chat.to)); + LOG_DEBUG("Compressed chat to '%s' - %d bytes\n", compressed.payload_variant.chat.to, length); + } } mp.decoded.payload.size = pb_encode_to_bytes(mp.decoded.payload.bytes, sizeof(mp.decoded.payload.bytes), meshtastic_TAKPacket_fields, &compressed); @@ -117,6 +126,14 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast uncompressed.payload_variant.chat.message); LOG_DEBUG("Compressed chat message: %d bytes\n", strlen(t->payload_variant.chat.message)); LOG_DEBUG("Decompressed chat message: '%s' @ %d bytes\n", uncompressed.payload_variant.chat.message, length); + + if (t->payload_variant.chat.has_to) { + uncompressed.payload_variant.chat.has_to = true; + length = unishox2_decompress_simple(t->payload_variant.chat.to, strlen(t->payload_variant.chat.to), + uncompressed.payload_variant.chat.to); + LOG_DEBUG("Compressed chat to: %d bytes\n", strlen(t->payload_variant.chat.to)); + LOG_DEBUG("Decompressed chat to: '%s' @ %d bytes\n", uncompressed.payload_variant.chat.to, length); + } } decompressedCopy->decoded.payload.size = pb_encode_to_bytes(decompressedCopy->decoded.payload.bytes, sizeof(decompressedCopy->decoded.payload),