brmesh/components/brmesh/debug.h
Jonas Rabenstein 771c1f6e32 initial draft
2025-12-22 01:45:30 +01:00

31 lines
1,004 B
C++

#pragma once
#include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#include <span>
namespace esphome {
namespace brmesh {
namespace {
template <typename...types>
void hexdump(const char *TAG, const uint8_t *data, size_t size, const char *fmt, types&&...args) {
// TODO: conditional format_hex_pretty
const auto hex = format_hex_pretty(data, size);
ESP_LOGD(TAG, fmt, std::forward<types>(args)..., hex.c_str());
}
template <typename...types>
void hexdump(const char *TAG, const void *data, size_t size, const char *fmt, types&&...args) {
hexdump(TAG, static_cast<const uint8_t *>(data), size, fmt, std::forward<types>(args)...);
}
template <typename...types, typename base_type, size_t size>
void hexdump(const char *TAG, const std::span<base_type, size> &span, const char *fmt, types&&...args) {
hexdump(TAG, static_cast<const void*>(&span.front()), span.size_bytes(), fmt, std::forward<types>(args)...);
}
} // namespace
} // namespace brmesh
} // namespace esphome