ATAK plugin (#3189)

* 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
This commit is contained in:
Ben Meadors
2024-02-09 20:31:10 -06:00
committed by GitHub
parent bcbc2f229d
commit 1085b54069
6 changed files with 195 additions and 20 deletions

View File

@@ -30,6 +30,10 @@ template <class T> class ProtobufModule : protected SinglePortModule
*/
virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, T *decoded) = 0;
/** Called to make changes to a particular incoming message
*/
virtual void alterReceivedProtobuf(meshtastic_MeshPacket &mp, T *decoded){};
/**
* Return a mesh packet which has been preinited with a particular protobuf data payload and port number.
* You can then send this packet (after customizing any of the payload fields you might need) with
@@ -86,4 +90,26 @@ template <class T> class ProtobufModule : protected SinglePortModule
return handleReceivedProtobuf(mp, decoded) ? ProcessMessage::STOP : ProcessMessage::CONTINUE;
}
/** Called to alter a particular incoming message
*/
virtual void alterReceived(meshtastic_MeshPacket &mp) override
{
auto &p = mp.decoded;
T scratch;
T *decoded = NULL;
if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) {
memset(&scratch, 0, sizeof(scratch));
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
decoded = &scratch;
} else {
LOG_ERROR("Error decoding protobuf module!\n");
// if we can't decode it, nobody can process it!
return;
}
}
return alterReceivedProtobuf(mp, decoded);
}
};