1
0
Fork 0

Logging improvements WRT handshake

This commit is contained in:
Shawn Nock 2019-07-16 15:25:37 -04:00
parent 0fb0118ffa
commit 3cede6be0f
2 changed files with 26 additions and 18 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13.1)
set(CONF_FILE c3.conf)
set(CONF_FILE application-c3wireless_em_ble.conf)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(hci_uart_h5)

View File

@ -595,7 +595,7 @@ static void h5_init(void)
static int h5_open(struct device *unused)
{
LOG_DBG("Open");
LOG_DBG("h5_open");
hci_uart_dev = device_get_binding(CONFIG_BT_CTLR_TO_HOST_UART_DEV_NAME);
if (!hci_uart_dev) {
@ -622,7 +622,7 @@ static int h5_open(struct device *unused)
#if defined(CONFIG_BT_CTLR_ASSERT_HANDLER)
void bt_ctlr_assert_handle(char *file, u32_t line)
{
printk("BT_CTLR Assert %s:%u", file, line);
LOG_ERR("BT_CTLR Assert %s:%u", file, line);
sys_reboot(SYS_REBOOT_COLD);
}
#endif /* CONFIG_BT_CTLR_ASSERT_HANDLER */
@ -672,7 +672,7 @@ static struct gpio_callback gpio_cb;
void gpio_callback(struct device *port,
struct gpio_callback *cb, u32_t pins) {
printk("Host wants the bootloader, rebooting\n");
LOG_ERR("Host wants the bootloader, rebooting\n");
k_sleep(250);
sys_reboot(SYS_REBOOT_COLD);
}
@ -683,23 +683,23 @@ void gpio_init() {
int ret;
gpio_dev = device_get_binding("GPIO_0");
if (!gpio_dev) {
printk("Cannot find %s!\n", "GPIO_0");
LOG_ERR("Cannot find %s!\n", "GPIO_0");
}
ret = gpio_pin_configure(gpio_dev, BOOTLOADER_REQ_GPIO_PIN,
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE | GPIO_INT_ACTIVE_LOW | GPIO_PUD_PULL_UP));
if (ret) {
printk("Error configuring GPIO_%d!\n", BOOTLOADER_REQ_GPIO_PIN);
LOG_ERR("Error configuring GPIO_%d!\n", BOOTLOADER_REQ_GPIO_PIN);
}
gpio_init_callback(&gpio_cb, gpio_callback, BIT(BOOTLOADER_REQ_GPIO_PIN));
ret = gpio_add_callback(gpio_dev, &gpio_cb);
if (ret) {
printk("Cannot setup callback!\n");
LOG_ERR("Cannot setup callback!\n");
}
ret = gpio_pin_enable_callback(gpio_dev, BOOTLOADER_REQ_GPIO_PIN);
if (ret) {
printk("Error enabling callback!\n");
LOG_ERR("Error enabling callback!\n");
}
}
@ -707,8 +707,10 @@ void gpio_init() {
static linkstate_t do_uninit(struct net_buf const *buf) {
if (packet_is_sync_response(buf)) {
h5_send_config();
LOG_DBG("RX'd SYNC RESPONSE: UNINIT -> INIT");
return INIT;
} else {
LOG_DBG("RX'd Incorrect Type: UNINIT -> UNINIT");
/* SYNC is the answer to any non-SYNC_RESP packets in UNINIT state */
h5_send_sync();
return UNINIT;
@ -720,33 +722,38 @@ static linkstate_t do_init(struct net_buf const *buf) {
h5.tx_win = conf_rsp[2] & 0x7;
h5.tx_seq = 0;
h5.tx_ack = 0;
LOG_DBG("Finished H5 configuration, tx_win %u", h5.tx_win);
LOG_DBG("Finished H5 configuration, tx_win %u: INIT -> ACTIVE", h5.tx_win);
return ACTIVE;
}
if (packet_is_config(buf)) {
LOG_DBG("RX'd CONFIG: INIT -> INIT");
h5_send_config_response();
} else {
LOG_DBG("RX'd Other: INIT -> INIT");
}
return INIT;
}
static linkstate_t do_active(struct net_buf *buf) {
if (packet_is_config(buf)) {
h5_send_config_response();
return ACTIVE;
}
if (packet_is_config_response(buf)) {
return ACTIVE;
}
if (packet_is_sync_response(buf) || packet_is_config(buf)) {
LOG_DBG("Bad packet for ACTIVE state: ACTIVE -> UNINIT");
h5_send_sync();
return UNINIT;
}
if (packet_is_config(buf)) {
h5_send_config_response();
LOG_DBG("RX'd CONFIG: ACTIVE -> ACTIVE");
}
if (packet_is_config_response(buf)) {
LOG_DBG("RX'd CONFIG RESPONSE: ACTIVE -> ACTIVE");
}
// Presumably something from the controller
if (bt_buf_get_type(buf) == BT_BUF_EVT) {
LOG_DBG("RX'd CONTROLLER EVENT: ACTIVE -> ACTIVE");
h5_send(buf->data, HCI_EVENT_PKT, buf->len);
} else {
LOG_HEXDUMP_ERR(buf->data, buf->len, "Unexpected buffer in host_queue");
@ -766,6 +773,7 @@ void main(void)
buf = net_buf_get(&h5.host_queue, K_FOREVER);
if (packet_is_sync(buf)) {
LOG_DBG("RX'd SYNC: %d -> UNINIT", h5.link_state);
h5.link_state = UNINIT;
h5_send_sync_response();
goto next;