mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
45 lines
883 B
C
45 lines
883 B
C
/*
|
|
* Copyright (c) 2017 Nordic Semiconductor ASA
|
|
* Copyright (c) 2016 Vinayak Kariappa Chettimada
|
|
* Copyright (c) 2015-2016 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <string.h>
|
|
|
|
#include "mesh_types.h"
|
|
#include "mesh_util.h"
|
|
|
|
const char *bt_hex(const void *buf, size_t len)
|
|
{
|
|
static const char hex[] = "0123456789abcdef";
|
|
static char hexbufs[2][129];
|
|
static u8_t curbuf;
|
|
const u8_t *b = buf;
|
|
char *str = NULL;
|
|
int i;
|
|
|
|
str = hexbufs[curbuf++];
|
|
curbuf %= ARRAY_SIZE(hexbufs);
|
|
|
|
len = MIN(len, (sizeof(hexbufs[0]) - 1) / 2);
|
|
|
|
for (i = 0; i < len; i++) {
|
|
str[i * 2] = hex[b[i] >> 4];
|
|
str[i * 2 + 1] = hex[b[i] & 0xf];
|
|
}
|
|
|
|
str[i * 2] = '\0';
|
|
|
|
return str;
|
|
}
|
|
|
|
void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len)
|
|
{
|
|
src += len;
|
|
while (len--) {
|
|
*dst++ = *--src;
|
|
}
|
|
}
|