diff --git a/components/log/include/esp_log.h b/components/log/include/esp_log.h index 6a9550046..928fb4905 100644 --- a/components/log/include/esp_log.h +++ b/components/log/include/esp_log.h @@ -102,10 +102,10 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, . * * @param buffer Pointer to the buffer array * - * @param buff_len length of buffer + * @param buff_len length of buffer in bytes * */ -void esp_log_buffer_hex(const char *tag, const char *buffer, uint16_t buff_len); +void esp_log_buffer_hex(const char *tag, const void *buffer, uint16_t buff_len); /** * @brief Log a buffer of characters at Info level. Buffer should contain only printable characters. @@ -114,7 +114,7 @@ void esp_log_buffer_hex(const char *tag, const char *buffer, uint16_t buff_len); * * @param buffer Pointer to the buffer array * - * @param buff_len length of buffer + * @param buff_len length of buffer in bytes * */ void esp_log_buffer_char(const char *tag, const char *buffer, uint16_t buff_len); diff --git a/components/log/log.c b/components/log/log.c index c5c1334d3..1541727da 100644 --- a/components/log/log.c +++ b/components/log/log.c @@ -319,12 +319,13 @@ uint32_t esp_log_timestamp() __attribute__((alias("esp_log_early_timestamp"))); #endif //BOOTLOADER_BUILD -void esp_log_buffer_hex(const char *tag, const char *buffer, uint16_t buff_len) +void esp_log_buffer_hex(const char *tag, const void *buffer, uint16_t buff_len) { + const char *as_bytes = (const char *)buffer; char temp_buffer[3*BYTES_PER_LINE + 1]= {0}; int line_len = 0; for (int i = 0; i < buff_len; i++) { - line_len += sprintf(temp_buffer+line_len, "%02x ", buffer[i]); + line_len += sprintf(temp_buffer+line_len, "%02x ", as_bytes[i]); if (((i + 1) % BYTES_PER_LINE == 0) || (i == buff_len - 1)) { ESP_LOGI(tag, "%s", temp_buffer); line_len = 0;