/*!
 * In Samsung Ukraine R&D Center (SRK) under a contract between
 * LLC "Samsung Electronics Ukraine Company" (Kyiv, Ukraine)
 * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
 * Copyright: (c) Samsung Electronics Co, Ltd 2019. All rights reserved.
 *
 */


#include <string.h>
#include <stdint.h>

#include "tz_debug.h"


void hex_print_tag(char* tag, uint8_t *data, uint32_t len)
{
    if (NULL == data || len < 1 || tag == NULL) {
        LOGI("Invalid parameters.");
    } else {
        uint32_t i = 0, write_size = 0, total_size = len;
        char print_buffer[200];
        char temp[3];
        LOGI("%s data size : %u", tag, len);

        while (total_size > write_size) {
            memset(print_buffer, 0, 200);
            memset(temp, 0, 3);
            for (i = write_size; i < len && i-write_size < 32 ; i++) {
                snprintf(temp, 3, "%02X", data[i]);
                strcat(print_buffer, temp);
            }
            LOGI("0x%s", print_buffer);
            write_size = i;
        }

    }
}

void hex_print_tag_debug(char* tag, uint8_t *data, uint32_t len)
{
#ifdef DEBUG_LOW
    hex_print_tag(tag, data, len);
#else
    (void)tag;
    (void)data;
    (void)len;
#endif
}
