Allows tx_thread to respond more quickly to state changes
This commit is contained in:
parent
b0d6659517
commit
34a40c8180
23
src/main.c
23
src/main.c
|
@ -628,12 +628,9 @@ static void tx_thread(void)
|
||||||
k_sleep(250);
|
k_sleep(250);
|
||||||
break;
|
break;
|
||||||
case ACTIVE:
|
case ACTIVE:
|
||||||
buf = net_buf_get(&h5.controller_queue, K_MSEC(250));
|
while ((buf = net_buf_get(&h5.controller_queue, K_MSEC(100)))) {
|
||||||
if (!buf) {
|
bt_send(buf);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
//LOG_HEXDUMP_DBG(buf->data, buf->len, "TX_QUEUE -> CTRL");
|
|
||||||
bt_send(buf);
|
|
||||||
|
|
||||||
/* buf is dequeued from tx_queue and queued to unack
|
/* buf is dequeued from tx_queue and queued to unack
|
||||||
* queue.
|
* 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)
|
void main(void)
|
||||||
{
|
{
|
||||||
LOG_DBG("Start");
|
LOG_DBG("Start");
|
||||||
|
@ -901,13 +906,13 @@ void main(void)
|
||||||
|
|
||||||
switch (h5.link_state) {
|
switch (h5.link_state) {
|
||||||
case UNINIT:
|
case UNINIT:
|
||||||
h5.link_state = do_uninit(buf);
|
state_change(h5.link_state, do_uninit(buf));
|
||||||
break;
|
break;
|
||||||
case INIT:
|
case INIT:
|
||||||
h5.link_state = do_init(buf);
|
state_change(h5.link_state, do_init(buf));
|
||||||
break;
|
break;
|
||||||
case ACTIVE:
|
case ACTIVE:
|
||||||
h5.link_state = do_active(buf);
|
state_change(h5.link_state, do_active(buf));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
net_buf_unref(buf);
|
net_buf_unref(buf);
|
||||||
|
|
Loading…
Reference in New Issue