From 0fb0118ffad2c965b7d1f7c2000688ee131b4574 Mon Sep 17 00:00:00 2001 From: Shawn Nock Date: Tue, 16 Jul 2019 13:31:27 -0400 Subject: [PATCH] Ensure state set correctly on exit from state transform functions --- src/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index b8f4d14..213f7e2 100644 --- a/src/main.c +++ b/src/main.c @@ -716,19 +716,20 @@ static linkstate_t do_uninit(struct net_buf const *buf) { } static linkstate_t do_init(struct net_buf const *buf) { - if (packet_is_config(buf)) { - h5_send_config_response(); - return INIT; - } else if (packet_is_config_response(buf)) { + if (packet_is_config_response(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); return ACTIVE; } + if (packet_is_config(buf)) { + h5_send_config_response(); + } + return INIT; } -static linkstate_t do_active(struct net_buf const *buf) { +static linkstate_t do_active(struct net_buf *buf) { if (packet_is_config(buf)) { h5_send_config_response(); return ACTIVE; @@ -745,13 +746,12 @@ static linkstate_t do_active(struct net_buf const *buf) { } // Presumably something from the controller - u8_t type = bt_buf_get_type(buf); - if (type == BT_BUF_EVT) { - //LOG_HEXDUMP_DBG(buf->data, buf->len, "CTRL -> HOST"); + if (bt_buf_get_type(buf) == BT_BUF_EVT) { h5_send(buf->data, HCI_EVENT_PKT, buf->len); } else { LOG_HEXDUMP_ERR(buf->data, buf->len, "Unexpected buffer in host_queue"); } + return ACTIVE; } void main(void)