diff --git a/inc/Message.hpp b/inc/Message.hpp index 3430c38eccb6548a6f53426022c3d1fb2eb29de7..93821cbe1bed298eb0080f70a295954824a360c3 100644 --- a/inc/Message.hpp +++ b/inc/Message.hpp @@ -367,6 +367,17 @@ public: appendString(string); } + /** + * Adds a nested TC or TM Message within the current Message + * + * As a design decision, nested TC & TM Messages always have a fixed width, specified in \ref ECSSDefinitions. This + * reduces the uncertainty and complexity of having to parse the nested Message itself to see how long it is, at + * the cost of more data to be transmitted. + * @param message The message to append + * @param size The fixed number of bytes that the message will take up. The empty last bytes are padded with 0s. + */ + void appendMessage(const Message & message, uint16_t size); + /** * Fetches a single-byte boolean value from the current position in the message * diff --git a/src/Message.cpp b/src/Message.cpp index 55e9d49d0cb91e099201e41afb451e681421cc78..e96eacaab14cc30c143abb607ad09bb423358abe 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -3,6 +3,7 @@ #include <cstring> #include <ErrorHandler.hpp> #include <ServicePool.hpp> +#include <MessageParser.hpp> Message::Message(uint8_t serviceType, uint8_t messageType, Message::PacketType packetType, uint16_t applicationId) : serviceType(serviceType), messageType(messageType), packetType(packetType), applicationId(applicationId) {} @@ -161,3 +162,7 @@ void Message::resetRead() { readPosition = 0; currentBit = 0; } + +void Message::appendMessage(const Message& message, uint16_t size) { + appendString(MessageParser::composeECSS(message, size)); +}