diff --git a/src/main.c b/src/main.c index fd09cfb..e4c906e 100644 --- a/src/main.c +++ b/src/main.c @@ -533,7 +533,7 @@ static void unproc_thread(void) { //LOG_HEXDUMP_DBG((uint8_t*)&hdr, sizeof(hdr), "Header"); if (hdr.is_reliable) { - LOG_DBG("Header: seq %d, ack %d, rel: %s, crc16: %s", hdr.seq, hdr.ack, + LOG_DBG("Header: seq %d, ack %d, rel: %s, has_crc16: %s", hdr.seq, hdr.ack, hdr.is_reliable ? "true" : "false", hdr.crc_after_payload ? "true" : "false"); } @@ -637,7 +637,7 @@ static void tx_thread(void) k_sleep(250); break; case ACTIVE: - while ((buf = net_buf_get(&h5.controller_queue, K_MSEC(100)))) { + while ((buf = net_buf_get(&h5.controller_queue, K_FOREVER))) { bt_send(buf); } //LOG_DBG("controller_queue empty"); @@ -886,6 +886,7 @@ static linkstate_t do_active(struct net_buf *buf) { // Presumably something from the controller if (bt_buf_get_type(buf) == BT_BUF_EVT) { h5_send(buf->data, HCI_EVENT_PKT, buf->len); + k_yield(); } else { LOG_HEXDUMP_ERR(buf->data, buf->len, "Unexpected buffer in host_queue"); } @@ -898,7 +899,11 @@ void state_change(int old, int new) { return; } h5.link_state = new; - k_wakeup(&tx_thread_data); + if (old != ACTIVE) { + k_wakeup(&tx_thread_data); + } else { + k_fifo_cancel_wait(&h5.controller_queue); + } } void main(void)