feat: format messages as hex

This commit is contained in:
2025-11-18 13:43:15 -05:00
parent 9cbe49355c
commit 133554bb1a

View File

@@ -1,5 +1,7 @@
#include "uart_mitm.h"
#include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#define RX_SUPPRESS_INTERVAL 50 // Time in ms to suppress rx after tx on same bus
#define RX_BLOCK_INTERVAL 50 // Time in ms to block before preparing a message to ship.
#define RX_BUF_LEN 64 // Time in ms to block before preparing a message to ship.
@@ -26,7 +28,8 @@ void UARTMITM::loop() {
this->uart1_->read_byte(&c);
if (rx1_block_until < millis()) { // current millis is after our blocking deadline; we can ship
// ... so ship!
ESP_LOGD(TAG, "RX1: We're gonna ship rx1!");
std::string hexString = format_hex(rx1_buffer, rx1_buffer_idx + 1);
ESP_LOGD(TAG, "RX1: %s", hexString.c_str());
rx1_buffer_idx = 0;
}
@@ -46,7 +49,8 @@ void UARTMITM::loop() {
this->uart2_->read_byte(&c);
if (rx2_block_until < millis()) { // current millis is after our blocking deadline; we can ship
// ... so ship!
ESP_LOGD(TAG, "RX2: We're gonna ship rx2!");
std::string hexString = format_hex(rx2_buffer, rx2_buffer_idx + 1);
ESP_LOGD(TAG, "RX2: %s", hexString.c_str());
rx2_buffer_idx = 0;
}