static void tx_fiber(void) { BT_DBG(""); /* FIXME: make periodic sending */ h5_send(sync_req, HCI_3WIRE_LINK_PKT, sizeof(sync_req)); while (true) { struct net_buf *buf; uint8_t type; BT_DBG("link_state %u", h5.link_state); switch (h5.link_state) { case UNINIT: /* FIXME: send sync */ fiber_sleep(10); break; case INIT: /* FIXME: send conf */ fiber_sleep(10); break; case ACTIVE: buf = nano_fifo_get(&h5.tx_queue, TICKS_UNLIMITED); type = h5_get_type(buf); h5_send(buf->data, type, buf->len); /* buf is dequeued from tx_queue and queued to unack * queue. */ nano_fifo_put(&h5.unack_queue, buf); unack_queue_len++; if (h5.retx_to) { fiber_delayed_start_cancel(h5.retx_to); } h5.retx_to = fiber_delayed_start(retx_stack, sizeof(retx_stack), retx_fiber, 0, 0, 7, 0, H5_TX_ACK_TIMEOUT); break; } } }
static void tx_thread(void) { BT_DBG(""); /* FIXME: make periodic sending */ h5_send(sync_req, HCI_3WIRE_LINK_PKT, sizeof(sync_req)); while (true) { struct net_buf *buf; u8_t type; BT_DBG("link_state %u", h5.link_state); switch (h5.link_state) { case UNINIT: /* FIXME: send sync */ k_sleep(100); break; case INIT: /* FIXME: send conf */ k_sleep(100); break; case ACTIVE: buf = net_buf_get(&h5.tx_queue, K_FOREVER); type = h5_get_type(buf); h5_send(buf->data, type, buf->len); /* buf is dequeued from tx_queue and queued to unack * queue. */ net_buf_put(&h5.unack_queue, buf); unack_queue_len++; k_delayed_work_submit(&retx_work, H5_TX_ACK_TIMEOUT); break; } } }