mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 00:31:58 +00:00
[vbus] Use stack-based hex formatting in verbose logging
This commit is contained in:
@@ -8,6 +8,9 @@ namespace vbus {
|
|||||||
|
|
||||||
static const char *const TAG = "vbus";
|
static const char *const TAG = "vbus";
|
||||||
|
|
||||||
|
// Maximum bytes to log in verbose hex output (16 frames * 4 bytes = 64 bytes typical)
|
||||||
|
static constexpr size_t VBUS_MAX_LOG_BYTES = 64;
|
||||||
|
|
||||||
void VBus::dump_config() {
|
void VBus::dump_config() {
|
||||||
ESP_LOGCONFIG(TAG, "VBus:");
|
ESP_LOGCONFIG(TAG, "VBus:");
|
||||||
check_uart_settings(9600);
|
check_uart_settings(9600);
|
||||||
@@ -101,8 +104,11 @@ void VBus::loop() {
|
|||||||
this->buffer_.push_back(this->fbytes_[i]);
|
this->buffer_.push_back(this->fbytes_[i]);
|
||||||
if (++this->cframe_ < this->frames_)
|
if (++this->cframe_ < this->frames_)
|
||||||
continue;
|
continue;
|
||||||
|
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
|
||||||
|
char hex_buf[format_hex_size(VBUS_MAX_LOG_BYTES)];
|
||||||
|
#endif
|
||||||
ESP_LOGV(TAG, "P2 C%04x %04x->%04x: %s", this->command_, this->source_, this->dest_,
|
ESP_LOGV(TAG, "P2 C%04x %04x->%04x: %s", this->command_, this->source_, this->dest_,
|
||||||
format_hex(this->buffer_).c_str());
|
format_hex_to(hex_buf, this->buffer_.data(), this->buffer_.size()));
|
||||||
for (auto &listener : this->listeners_)
|
for (auto &listener : this->listeners_)
|
||||||
listener->on_message(this->command_, this->source_, this->dest_, this->buffer_);
|
listener->on_message(this->command_, this->source_, this->dest_, this->buffer_);
|
||||||
this->state_ = 0;
|
this->state_ = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user