#pragma once #include #include #include #include #include "secsgem/secs2/item.hpp" namespace secsgem::secs2 { // A logical SECS-II message: stream/function, the W-bit (reply expected), and // an optional root data item as the body. The transport (HSMS) header carries // stream/function/W on the wire; the body bytes are the encoded root item. struct Message { uint8_t stream = 0; uint8_t function = 0; bool reply_expected = false; // W-bit std::optional body; Message() = default; Message(uint8_t s, uint8_t f, bool w, std::optional b = std::nullopt) : stream(s), function(f), reply_expected(w), body(std::move(b)) {} // Encode the body item to bytes (empty if there is no body). std::vector encode_body() const; // Build a Message from stream/function/W and raw body bytes (empty -> no body). static Message from_body(uint8_t stream, uint8_t function, bool reply_expected, const std::vector& body_bytes); // e.g. S1F2 W // > std::string sml() const; }; } // namespace secsgem::secs2