/**
 * @file lions.hpp
 *
 * @brief LMsg defenition.
 * LMsg is a class that represents a message in the Lions protocol.
 * 
 * This file contains the implementation of the message classes generated by the Lions Compiler.
 * 
 * @details
 * This file was generated by the Lions Compiler (https://github.com/ItsNotSoftware/lions) on {{date}}.
 * Modifying this file manually is not recommended as it may lead to unexpected behavior.
 * 
 * @note
 * Generated files should not be manually edited.
 * 
 * @author Lions Compiler
*/

#ifndef LMSG_HPP
#define LMSG_HPP

#include <cstdint>

namespace lions {

constexpr uint8_t MAX_PAYLOAD_SIZE = 248;

struct Header {
    uint8_t src;
    uint8_t dst;
    uint8_t next_hop;
    uint8_t msg_id;

    union{
        uint16_t checksum;

        struct{
            uint8_t checksum_low;
            uint8_t checksum_high;
        };
    };
};

class LMsg {
   public:
    Header header;
    uint8_t payload[MAX_PAYLOAD_SIZE];
    uint8_t payload_size;

    LMsg(uint8_t payload_size = 0);
    uint16_t calculate_checksum();
    bool valid_checksum();
};

}  // namespace lions

#endif