mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 03:40:47 +00:00
added hexdumpf
This commit is contained in:
parent
85742615a8
commit
fefe918692
@ -132,6 +132,7 @@ void swap128(const uint8_t src[16], uint8_t dst[16]);
|
||||
|
||||
void printf_hexdump(const void *data, int size);
|
||||
void hexdump(const void *data, int size);
|
||||
void hexdumpf(const void *data, int size);
|
||||
void printUUID128(uint8_t *uuid);
|
||||
void log_key(const char * name, sm_key_t key);
|
||||
|
||||
|
27
src/utils.c
27
src/utils.c
@ -142,6 +142,33 @@ void hexdump(const void *data, int size){
|
||||
}
|
||||
}
|
||||
|
||||
void hexdumpf(const void *data, int size){
|
||||
char buffer[6*16+1];
|
||||
int i, j;
|
||||
|
||||
uint8_t low = 0x0F;
|
||||
uint8_t high = 0xF0;
|
||||
j = 0;
|
||||
for (i=0; i<size;i++){
|
||||
uint8_t byte = ((uint8_t *)data)[i];
|
||||
buffer[j++] = '0';
|
||||
buffer[j++] = 'x';
|
||||
buffer[j++] = char_for_nibble((byte & high) >> 4);
|
||||
buffer[j++] = char_for_nibble(byte & low);
|
||||
buffer[j++] = ',';
|
||||
buffer[j++] = ' ';
|
||||
if (j >= 6*16 ){
|
||||
buffer[j] = 0;
|
||||
printf("%s", buffer);
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
if (j != 0){
|
||||
buffer[j] = 0;
|
||||
printf("%s", buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void log_key(const char * name, sm_key_t key){
|
||||
log_info("%-6s ", name);
|
||||
hexdump(key, 16);
|
||||
|
Loading…
x
Reference in New Issue
Block a user