Skip to content

Commit

Permalink
Fix - Add GeoChat To field to payloads and handle compression (#3199)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thebentern authored Feb 10, 2024
1 parent 514c19a commit 404d0dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion protobufs
17 changes: 17 additions & 0 deletions src/modules/AtakPluginModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 404d0dd

Please sign in to comment.