2016-04-20 22:54:07 +08:00
|
|
|
/** @file
|
|
|
|
* @brief Custom monitor protocol logging over UART
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-04-20 22:54:07 +08:00
|
|
|
*/
|
|
|
|
|
2017-08-09 14:21:11 +08:00
|
|
|
#if defined(CONFIG_BT_DEBUG_MONITOR)
|
2016-04-20 22:54:07 +08:00
|
|
|
|
|
|
|
#define BT_MONITOR_NEW_INDEX 0
|
|
|
|
#define BT_MONITOR_DEL_INDEX 1
|
|
|
|
#define BT_MONITOR_COMMAND_PKT 2
|
|
|
|
#define BT_MONITOR_EVENT_PKT 3
|
|
|
|
#define BT_MONITOR_ACL_TX_PKT 4
|
|
|
|
#define BT_MONITOR_ACL_RX_PKT 5
|
|
|
|
#define BT_MONITOR_SCO_TX_PKT 6
|
|
|
|
#define BT_MONITOR_SCO_RX_PKT 7
|
|
|
|
#define BT_MONITOR_OPEN_INDEX 8
|
|
|
|
#define BT_MONITOR_CLOSE_INDEX 9
|
|
|
|
#define BT_MONITOR_INDEX_INFO 10
|
|
|
|
#define BT_MONITOR_VENDOR_DIAG 11
|
|
|
|
#define BT_MONITOR_SYSTEM_NOTE 12
|
|
|
|
#define BT_MONITOR_USER_LOGGING 13
|
|
|
|
#define BT_MONITOR_NOP 255
|
|
|
|
|
|
|
|
#define BT_MONITOR_TYPE_PRIMARY 0
|
|
|
|
#define BT_MONITOR_TYPE_AMP 1
|
|
|
|
|
2016-05-05 02:19:49 +08:00
|
|
|
/* Extended header types */
|
|
|
|
#define BT_MONITOR_COMMAND_DROPS 1
|
|
|
|
#define BT_MONITOR_EVENT_DROPS 2
|
|
|
|
#define BT_MONITOR_ACL_RX_DROPS 3
|
|
|
|
#define BT_MONITOR_ACL_TX_DROPS 4
|
|
|
|
#define BT_MONITOR_SCO_RX_DROPS 5
|
|
|
|
#define BT_MONITOR_SCO_TX_DROPS 6
|
|
|
|
#define BT_MONITOR_OTHER_DROPS 7
|
|
|
|
#define BT_MONITOR_TS32 8
|
|
|
|
|
2017-03-28 18:58:05 +08:00
|
|
|
#define BT_MONITOR_BASE_HDR_LEN 6
|
|
|
|
|
2017-08-09 14:21:11 +08:00
|
|
|
#if defined(CONFIG_BT_BREDR)
|
2017-03-28 18:58:05 +08:00
|
|
|
#define BT_MONITOR_EXT_HDR_MAX 19
|
|
|
|
#else
|
|
|
|
#define BT_MONITOR_EXT_HDR_MAX 15
|
|
|
|
#endif
|
|
|
|
|
2016-04-20 22:54:07 +08:00
|
|
|
struct bt_monitor_hdr {
|
2017-04-21 01:00:29 +08:00
|
|
|
u16_t data_len;
|
|
|
|
u16_t opcode;
|
|
|
|
u8_t flags;
|
|
|
|
u8_t hdr_len;
|
2016-05-05 02:19:49 +08:00
|
|
|
|
2017-04-21 01:00:29 +08:00
|
|
|
u8_t ext[BT_MONITOR_EXT_HDR_MAX];
|
2017-03-28 18:58:05 +08:00
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct bt_monitor_ts32 {
|
2017-04-21 01:00:29 +08:00
|
|
|
u8_t type;
|
|
|
|
u32_t ts32;
|
2016-04-20 22:54:07 +08:00
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct bt_monitor_new_index {
|
2017-04-21 01:00:29 +08:00
|
|
|
u8_t type;
|
|
|
|
u8_t bus;
|
|
|
|
u8_t bdaddr[6];
|
2017-04-21 14:01:26 +08:00
|
|
|
char name[8];
|
2016-04-20 22:54:07 +08:00
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct bt_monitor_user_logging {
|
2017-04-21 01:00:29 +08:00
|
|
|
u8_t priority;
|
|
|
|
u8_t ident_len;
|
2016-04-20 22:54:07 +08:00
|
|
|
} __packed;
|
|
|
|
|
2017-04-21 01:00:29 +08:00
|
|
|
static inline u8_t bt_monitor_opcode(struct net_buf *buf)
|
2016-04-20 22:54:07 +08:00
|
|
|
{
|
|
|
|
switch (bt_buf_get_type(buf)) {
|
|
|
|
case BT_BUF_CMD:
|
|
|
|
return BT_MONITOR_COMMAND_PKT;
|
|
|
|
case BT_BUF_EVT:
|
|
|
|
return BT_MONITOR_EVENT_PKT;
|
|
|
|
case BT_BUF_ACL_OUT:
|
|
|
|
return BT_MONITOR_ACL_TX_PKT;
|
|
|
|
case BT_BUF_ACL_IN:
|
|
|
|
return BT_MONITOR_ACL_RX_PKT;
|
|
|
|
default:
|
|
|
|
return BT_MONITOR_NOP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-21 01:00:29 +08:00
|
|
|
void bt_monitor_send(u16_t opcode, const void *data, size_t len);
|
2016-04-20 22:54:07 +08:00
|
|
|
|
2017-04-21 01:00:29 +08:00
|
|
|
void bt_monitor_new_index(u8_t type, u8_t bus, bt_addr_t *addr,
|
2016-04-20 22:54:07 +08:00
|
|
|
const char *name);
|
|
|
|
|
2017-08-09 14:21:11 +08:00
|
|
|
#else /* !CONFIG_BT_DEBUG_MONITOR */
|
2016-04-20 22:54:07 +08:00
|
|
|
|
|
|
|
#define bt_monitor_send(opcode, data, len)
|
|
|
|
#define bt_monitor_new_index(type, bus, addr, name)
|
|
|
|
|
|
|
|
#endif
|