92void init_frame(
IoFrame &f,
bool is_2w =
true,
bool start =
false,
bool end =
false,
bool low_power =
false);
107bool set_cmd(
IoFrame &f, uint8_t cmd,
const uint8_t *params =
nullptr, uint8_t params_len = 0);
131bool parse(
const uint8_t *buf, uint8_t buf_len,
IoFrame &f);
142bool hex_to_bytes(
const std::string &hex, uint8_t *out, uint8_t len);
158uint16_t
crc_ccitt(
const uint8_t *data, uint8_t len);
bool set_cmd(IoFrame &f, uint8_t cmd, const uint8_t *params, uint8_t params_len)
Set command and payload.
static constexpr uint8_t NODE_ID_SIZE
Device/node addresses are 3 bytes (e.g., "123ABC").
static constexpr uint8_t CTRL0_END
Control byte 0 (CTRL0) bit definitions.
static constexpr uint8_t FRAME_MAX_DATA_SIZE
Maximum data bytes after command ID.
bool is_start(const IoFrame &f)
Check START flag.
static constexpr uint8_t CTRL0_PROTOCOL_1W
Bit 5: 1=OneWay protocol, 0=TwoWay protocol.
static constexpr uint8_t CTRL0_START
Bit 6: first frame in exchange (uses long preamble).
static constexpr uint8_t CTRL1_ROUTED
Bit 6: frame was relayed through a repeater.
uint16_t crc_ccitt(const uint8_t *data, uint8_t len)
CRC-CCITT used by the IO-Homecontrol protocol for frame validation.
void init_frame(IoFrame &f, bool is_2w, bool start, bool end, bool low_power)
Initialize an IoFrame header (ctrl0/ctrl1) with flags.
uint8_t frame_length(const IoFrame &f)
Get total frame length from ctrl0.
void set_dst(IoFrame &f, const uint8_t id[NODE_ID_SIZE])
Set destination node ID.
bool is_end(const IoFrame &f)
Check END flag.
bool parse(const uint8_t *buf, uint8_t buf_len, IoFrame &f)
Parse a wire buffer into a parsed IoFrame (validates length and CTRL0).
std::string node_id_to_string(const uint8_t id[NODE_ID_SIZE])
Format a 3‑byte node ID as a 6‑character uppercase hex string.
static constexpr uint8_t CTRL1_PRIORITY
Bit 2: high-priority frame.
static constexpr uint8_t CTRL1_ACK
Bit 4: sender can handle 2W responses (ACK-capable).
static constexpr uint8_t CTRL0_LENGTH_MASK
Bits [4:0]: frame length - 1.
static constexpr uint8_t CTRL1_VERSION_MASK
Control byte 1 (CTRL1) bit definitions.
static constexpr uint8_t CTRL1_LOW_POWER
Bit 5: low-power device (e.g., solar-powered).
static constexpr uint8_t CTRL1_BEACON
Bit 7: beacon announcement frame.
bool hex_to_bytes(const std::string &hex, uint8_t *out, uint8_t len)
Convert a hex string (e.g., "123ABC") to a byte array.
uint8_t serialize(const IoFrame &f, uint8_t *buf, uint8_t buf_size)
Serialize a parsed frame into a wire buffer (without CRC).
void set_src(IoFrame &f, const uint8_t id[NODE_ID_SIZE])
Set source node ID.
Fundamental IO-Homecontrol frame and crypto size constants.
Parsed IO‑Homecontrol frame (CTRL0/1 + addresses + command + data).
uint8_t data[FRAME_MAX_DATA_SIZE]
Command parameters (0–23 bytes).
uint8_t ctrl0
Control byte 0: flags + length.
uint8_t src[NODE_ID_SIZE]
Source node ID (3 bytes).
uint8_t dst[NODE_ID_SIZE]
Destination node ID (3 bytes).
uint8_t data_len
Actual length of data.
uint8_t ctrl1
Control byte 1: low power, beacon, etc.