#ifndef PACKET_PARSER_H #define PACKET_PARSER_H #include #include // Define packet types enum class PacketType { OPEN, CLOSE, STOP, FIELDS, FIELD_COMMAND, UNKNOWN }; enum class FieldType { VALUE, SET, FETCH, UNKNOWN }; struct Field { uint8_t identifier; FieldType type; bool hasValue; std::variant value; }; struct FieldsParameters { std::vector fields; }; using PacketParameters = std::variant; // Define Message structure struct Packet { uint16_t source; uint16_t destination; PacketType type; PacketParameters parameters; }; class PacketParser { public: PacketParser(); ~PacketParser(); bool parsePacket(const uint8_t *buffer, Packet& message); private: bool parseFields(const uint8_t *buffer, std::vector& fields); }; #endif // PACKET_PARSER_H