esp_log_buffer_hex: Make buffer argument a void pointer

This commit is contained in:
Angus Gratton 2017-06-09 17:16:58 +10:00 committed by Angus Gratton
parent e7db29b2a8
commit edd2459934
2 changed files with 6 additions and 5 deletions

View File

@ -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);

View File

@ -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;