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]);
40 if ((ctrl1 & CTRL1_ACK) != 0)
41 pos += snprintf(out + pos, out_size - pos,
"[ACK]");
42 if ((ctrl1 & CTRL1_LOW_POWER) != 0)
43 pos += snprintf(out + pos, out_size - pos,
"[LPM]");
44 if ((ctrl1 & CTRL1_PRIORITY) != 0)
45 pos += snprintf(out + pos, out_size - pos,
"[PRIO]");
46 if ((ctrl1 & CTRL1_ROUTED) != 0)
47 pos += snprintf(out + pos, out_size - pos,
"[R]");
48 if ((ctrl1 & CTRL1_BEACON) != 0)
49 snprintf(out + pos, out_size - pos,
"[B]");
74#ifndef IOHOME_UNSAFE_LOG_KEY_MATERIAL
80 char header_hex[(FRAME_MIN_SIZE * 3) + 4];
81 bytes_to_hex(data, FRAME_MIN_SIZE, header_hex,
sizeof(header_hex));
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 =
"";
97 if (len >= FRAME_MIN_SIZE) {
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)
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.
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.
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...
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...