1
0
Fork 0

Allows tx_thread to respond more quickly to state changes

This commit is contained in:
Shawn Nock 2019-07-18 12:23:04 -04:00
parent b0d6659517
commit 34a40c8180
1 changed files with 14 additions and 9 deletions

View File

@ -628,12 +628,9 @@ static void tx_thread(void)
k_sleep(250);
break;
case ACTIVE:
buf = net_buf_get(&h5.controller_queue, K_MSEC(250));
if (!buf) {
break;
}
//LOG_HEXDUMP_DBG(buf->data, buf->len, "TX_QUEUE -> CTRL");
while ((buf = net_buf_get(&h5.controller_queue, K_MSEC(100)))) {
bt_send(buf);
}
/* buf is dequeued from tx_queue and queued to unack
* queue.
@ -888,6 +885,14 @@ static linkstate_t do_active(struct net_buf *buf) {
}
}
void state_change(int old, int new) {
if (old == new) {
return;
}
h5.link_state = new;
k_wakeup(&tx_thread_data);
}
void main(void)
{
LOG_DBG("Start");
@ -901,13 +906,13 @@ void main(void)
switch (h5.link_state) {
case UNINIT:
h5.link_state = do_uninit(buf);
state_change(h5.link_state, do_uninit(buf));
break;
case INIT:
h5.link_state = do_init(buf);
state_change(h5.link_state, do_init(buf));
break;
case ACTIVE:
h5.link_state = do_active(buf);
state_change(h5.link_state, do_active(buf));
break;
}
net_buf_unref(buf);