10#include "esphome/core/log.h"
22inline void bytes_to_hex(
const uint8_t *data, uint8_t len,
char *out,
size_t out_size) {
27 for (uint8_t i = 0; i < len && pos + 4 < out_size; i++)
28 pos += snprintf(out + pos, out_size - pos,
"%02X ", data[i]);
41 pos += snprintf(out + pos, out_size - pos,
"[ACK]");
43 pos += snprintf(out + pos, out_size - pos,
"[LPM]");
45 pos += snprintf(out + pos, out_size - pos,
"[PRIO]");
47 pos += snprintf(out + pos, out_size - pos,
"[R]");
49 snprintf(out + pos, out_size - pos,
"[B]");
74#ifndef IOHOME_UNSAFE_LOG_KEY_MATERIAL
82 snprintf(out, out_size,
"%s[%u bytes masked]", header_hex,
static_cast<unsigned>(len -
FRAME_MIN_SIZE));
89#ifdef IOHOME_FRAME_LOG
90inline void log_frame(
const char *prefix,
const uint8_t *data, uint8_t len, uint32_t freq, uint16_t preamble = 0) {
96 const char *cmd_str =
"";
103 ESP_LOGI(
"io_frame",
"%s [%u bytes] freq=%" PRIu32
" preamble=%u cmd=%s %s: %s", prefix, len, freq, preamble,
104 cmd_str, flags, hex);
106 ESP_LOGI(
"io_frame",
"%s [%u bytes] freq=%" PRIu32
" cmd=%s %s: %s", prefix, len, freq, cmd_str, flags, hex);
void bytes_to_hex(const uint8_t *data, uint8_t len, char *out, size_t out_size)
static constexpr uint8_t FRAME_MIN_SIZE
Minimum frame: CTRL0+CTRL1+DST(3)+SRC(3)+CMD(1).
void decode_ctrl1_flags(uint8_t ctrl1, char *out, size_t out_size)
Render decoded CTRL1 flags into a short annotation string.
const char * command_name(uint8_t cmd)
Get a human-readable name for any IO-Homecontrol command ID.
static constexpr uint8_t CTRL1_ROUTED
Bit 6: frame was relayed through a repeater.
void render_frame_hex_redacted(const uint8_t *data, uint8_t len, char *out, size_t out_size)
Render a frame's bytes as spaced hex text, masking the payload when the command carries key material ...
constexpr size_t FRAME_LOG_HEX_BUFFER_SIZE
Fits a full 32-byte frame rendered as spaced hex text.
constexpr size_t FRAME_LOG_FLAGS_BUFFER_SIZE
Buffer for decoded CTRL1 flag annotations.
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).
bool command_carries_key_material(uint8_t cmd)
Whether a frame command's payload carries key material that must never be logged or reported verbatim...
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.
static constexpr uint8_t FRAME_CMD_OFFSET
Byte offset of the command ID in a raw wire buffer.
IO-Homecontrol 2W frame container: control bytes, IoFrame and (de)serialization.
Key-material redaction helpers shared by every surface that can emit frame bytes or debug text (frame...