2#ifdef USE_UART_DEBUGGER
12static const char *
const TAG =
"uart_debug";
42 this->
bytes_.push_back(
byte);
105 size_t len = bytes.size();
107 for (
size_t i = 0; i <
len; i++) {
111 sprintf(buf,
"%02X", bytes[i]);
114 ESP_LOGD(TAG,
"%s", res.c_str());
125 size_t len = bytes.size();
127 for (
size_t i = 0; i <
len; i++) {
130 }
else if (bytes[i] == 8) {
132 }
else if (bytes[i] == 9) {
134 }
else if (bytes[i] == 10) {
136 }
else if (bytes[i] == 11) {
138 }
else if (bytes[i] == 12) {
140 }
else if (bytes[i] == 13) {
142 }
else if (bytes[i] == 27) {
144 }
else if (bytes[i] == 34) {
146 }
else if (bytes[i] == 39) {
148 }
else if (bytes[i] == 92) {
150 }
else if (bytes[i] < 32 || bytes[i] > 127) {
151 sprintf(buf,
"\\x%02X", bytes[i]);
158 ESP_LOGD(TAG,
"%s", res.c_str());
164 size_t len = bytes.size();
170 for (
size_t i = 0; i <
len; i++) {
176 ESP_LOGD(TAG,
"%s", res.c_str());
182 size_t len = bytes.size();
189 for (
size_t i = 0; i <
len; i++) {
193 sprintf(buf,
"0b" BYTE_TO_BINARY_PATTERN
" (0x%02X)", BYTE_TO_BINARY(bytes[i]), bytes[i]);
196 ESP_LOGD(TAG,
"%s", res.c_str());
void add_debug_callback(std::function< void(UARTDirection, uint8_t)> &&callback)
static void log_hex(UARTDirection direction, std::vector< uint8_t > bytes, uint8_t separator)
Log the bytes as hex values, separated by the provided separator character.
static void log_binary(UARTDirection direction, std::vector< uint8_t > bytes, uint8_t separator)
Log the bytes as '<binary> (<hex>)' values, separated by the provided separator.
static void log_string(UARTDirection direction, std::vector< uint8_t > bytes)
Log the bytes as string values, escaping unprintable characters.
static void log_int(UARTDirection direction, std::vector< uint8_t > bytes, uint8_t separator)
Log the bytes as integer values, separated by the provided separator character.
void store_byte_(UARTDirection direction, uint8_t byte)
UARTDirection for_direction_
void trigger_after_timeout_()
bool is_my_direction_(UARTDirection direction)
void trigger_after_direction_change_(UARTDirection direction)
size_t after_delimiter_pos_
std::vector< uint8_t > bytes_
std::vector< uint8_t > after_delimiter_
void trigger_after_delimiter_(uint8_t byte)
bool has_buffered_bytes_()
void trigger_after_bytes_()
UARTDirection last_direction_
UARTDebugger(UARTComponent *parent)
bool read_byte(uint8_t *data)
Providing packet encoding functions for exchanging data with a remote host.
std::string to_string(int value)
void IRAM_ATTR HOT delay(uint32_t ms)
uint32_t IRAM_ATTR HOT millis()