2016-07-04 00:37:38 +08:00
|
|
|
/* log.c - logging helpers */
|
|
|
|
|
|
|
|
/*
|
2017-05-10 22:27:16 +08:00
|
|
|
* Copyright (c) 2017 Nordic Semiconductor ASA
|
2016-07-04 00:37:38 +08:00
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-07-04 00:37:38 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Helper for printk parameters to convert from binary to hex.
|
|
|
|
* We declare multiple buffers so the helper can be used multiple times
|
|
|
|
* in a single printk call.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-19 23:32:08 +08:00
|
|
|
#include <zephyr/types.h>
|
2016-10-21 18:04:56 +08:00
|
|
|
#include <zephyr.h>
|
2016-07-04 00:37:38 +08:00
|
|
|
#include <misc/util.h>
|
2017-05-10 22:27:16 +08:00
|
|
|
#include <bluetooth/bluetooth.h>
|
|
|
|
#include <bluetooth/hci.h>
|
2016-07-04 00:37:38 +08:00
|
|
|
|
2018-10-17 19:09:40 +08:00
|
|
|
const char *bt_hex_real(const void *buf, size_t len)
|
2016-07-04 00:37:38 +08:00
|
|
|
{
|
|
|
|
static const char hex[] = "0123456789abcdef";
|
2018-10-17 19:09:40 +08:00
|
|
|
static char str[129];
|
2017-04-21 01:00:29 +08:00
|
|
|
const u8_t *b = buf;
|
2016-07-04 00:37:38 +08:00
|
|
|
int i;
|
|
|
|
|
2018-10-17 19:09:40 +08:00
|
|
|
len = min(len, (sizeof(hex) - 1) / 2);
|
2016-07-04 00:37:38 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2017-05-10 22:27:16 +08:00
|
|
|
|
2018-10-17 19:09:40 +08:00
|
|
|
const char *bt_addr_str_real(const bt_addr_t *addr)
|
2017-05-10 22:27:16 +08:00
|
|
|
{
|
2018-10-17 19:09:40 +08:00
|
|
|
static char str[BT_ADDR_STR_LEN];
|
2018-07-18 13:57:38 +08:00
|
|
|
|
2018-10-17 19:09:40 +08:00
|
|
|
bt_addr_to_str(addr, str, sizeof(str));
|
2017-05-10 22:27:16 +08:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2018-10-17 19:09:40 +08:00
|
|
|
const char *bt_addr_le_str_real(const bt_addr_le_t *addr)
|
2017-05-10 22:27:16 +08:00
|
|
|
{
|
2018-10-17 19:09:40 +08:00
|
|
|
static char str[BT_ADDR_LE_STR_LEN];
|
2017-05-10 22:27:16 +08:00
|
|
|
|
2018-10-17 19:09:40 +08:00
|
|
|
bt_addr_le_to_str(addr, str, sizeof(str));
|
2017-05-10 22:27:16 +08:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|