Bluetooth: EDTT: Replace printk with logging

Replace printk with logging, add additional log statements for command
handling.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2020-02-16 13:01:51 +01:00 committed by Johan Hedberg
commit 2c857f9f69

View file

@ -26,6 +26,15 @@
#include "bs_tracing.h"
#include "commands.h"
#if IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE)
#define LOG_LEVEL LOG_LEVEL_DBG
#else
#define LOG_LEVEL CONFIG_BT_LOG_LEVEL
#endif
#include <logging/log.h>
LOG_MODULE_REGISTER(hci_test_app);
static u16_t waiting_opcode;
static enum commands_t waiting_response;
static u8_t m_events;
@ -39,7 +48,7 @@ static void read_excess_bytes(u16_t size)
u8_t buffer[size];
edtt_read((u8_t *)buffer, size, EDTTT_BLOCK);
printk("command size wrong! (%u extra bytes removed)", size);
LOG_ERR("command size wrong! (%u extra bytes removed)", size);
}
}
@ -129,12 +138,13 @@ static int send_hci_command(u16_t opcode, u8_t param_len, u16_t response)
}
err = bt_send(buf);
if (err) {
printk("Failed to send HCI command %d (err %d)\n",
LOG_ERR("Failed to send HCI command %d (err %d)",
opcode, err);
error_response(err);
}
} else {
printk("Failed to create buffer for HCI command %u\n", opcode);
LOG_ERR("Failed to create buffer for HCI command 0x%04x",
opcode);
error_response(-1);
}
return err;
@ -179,10 +189,15 @@ static void command_complete(struct net_buf *buf)
u16_t size = sys_cpu_to_le16(buf->len);
if (opcode == waiting_opcode) {
LOG_DBG("Command complete for 0x%04x", waiting_opcode);
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
edtt_write((u8_t *)buf->data, buf->len, EDTTT_BLOCK);
waiting_opcode = 0;
} else {
LOG_WRN("Not waiting for 0x(%04x) command status,"
" expected 0x(%04x)", opcode, waiting_opcode);
}
}
@ -197,10 +212,15 @@ static void command_status(struct net_buf *buf)
u16_t size = sys_cpu_to_le16(buf->len);
if (opcode == waiting_opcode) {
LOG_DBG("Command status for 0x%04x", waiting_opcode);
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
edtt_write((u8_t *)buf->data, buf->len, EDTTT_BLOCK);
waiting_opcode = 0;
} else {
LOG_WRN("Not waiting for 0x(%04x) command status,"
" expected 0x(%04x)", opcode, waiting_opcode);
}
}
@ -249,6 +269,7 @@ static void service_events(void *p1, void *p2, void *p3)
bs_trace_raw_time(4,
"Failed to allocated buffer "
"for event!\n");
LOG_WRN("No event in queue");
}
struct bt_hci_evt_hdr *hdr = (void *)buf->data;
@ -479,12 +500,12 @@ static void le_data_write(u16_t size)
}
err = bt_send(buf);
if (err) {
printk("Failed to send ACL Data (err %d)\n",
LOG_ERR("Failed to send ACL Data (err %d)",
err);
}
} else {
err = -2; /* Failed to allocate data buffer */
printk("Failed to create buffer for ACL Data.\n");
LOG_ERR("Failed to create buffer for ACL Data.");
}
} else {
/* Size too small for header (handle and data length) */
@ -520,7 +541,7 @@ void main(void)
*/
err = bt_enable_raw(&rx_queue);
if (err) {
printk("Bluetooth initialization failed (err %d)\n", err);
LOG_ERR("Bluetooth initialization failed (err %d)", err);
return;
}
/**