diff --git a/nimble/controller/include/controller/ble_ll_conn.h b/nimble/controller/include/controller/ble_ll_conn.h index 451f70924..ab8c5205f 100644 --- a/nimble/controller/include/controller/ble_ll_conn.h +++ b/nimble/controller/include/controller/ble_ll_conn.h @@ -294,8 +294,6 @@ struct ble_ll_conn_sm struct os_callout auth_pyld_timer; #endif - struct os_callout rd_features_timer; - /* * XXX: a note on all these structures for control procedures. First off, * all of these need to be ifdef'd to save memory. Another thing to diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c index 864b94464..53fdca606 100644 --- a/nimble/controller/src/ble_ll_conn.c +++ b/nimble/controller/src/ble_ll_conn.c @@ -1916,11 +1916,6 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm) connsm); #endif - os_callout_init(&connsm->rd_features_timer, - &g_ble_ll_data.ll_evq, - ble_ll_conn_rd_features_timer_cb, - connsm); - ble_ll_conn_calc_itvl_ticks(connsm); /* Add to list of active connections */ @@ -2006,8 +2001,6 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err) os_callout_stop(&connsm->auth_pyld_timer); #endif - os_callout_stop(&connsm->rd_features_timer); - /* Remove from the active connection list */ SLIST_REMOVE(&g_ble_ll_conn_active_list, connsm, ble_ll_conn_sm, act_sle); @@ -2036,6 +2029,16 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err) /* Connection state machine is now idle */ connsm->conn_state = BLE_LL_CONN_STATE_IDLE; + /* + * If we have features and there's pending HCI command, send an event before + * disconnection event so it does make sense to host. + */ + if (connsm->csmflags.cfbit.pending_hci_rd_features && + connsm->csmflags.cfbit.rxd_features) { + ble_ll_hci_ev_rd_rem_used_feat(connsm, BLE_ERR_SUCCESS); + connsm->csmflags.cfbit.pending_hci_rd_features = 0; + } + /* * We need to send a disconnection complete event or a connection complete * event when the connection ends. We send a connection complete event @@ -2054,8 +2057,13 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err) } } + /* + * If there is still pending read features request HCI command, send an + * event to complete it. + */ if (connsm->csmflags.cfbit.pending_hci_rd_features) { ble_ll_hci_ev_rd_rem_used_feat(connsm, BLE_ERR_UNK_CONN_ID); + connsm->csmflags.cfbit.pending_hci_rd_features = 0; } /* Put connection state machine back on free list */ @@ -2533,6 +2541,13 @@ ble_ll_conn_event_end(struct os_event *ev) /* If we have completed packets, send an event */ ble_ll_conn_num_comp_pkts_event_send(connsm); + + /* If we have features and there's pending HCI command, send an event */ + if (connsm->csmflags.cfbit.pending_hci_rd_features && + connsm->csmflags.cfbit.rxd_features) { + ble_ll_hci_ev_rd_rem_used_feat(connsm, BLE_ERR_SUCCESS); + connsm->csmflags.cfbit.pending_hci_rd_features = 0; + } } /** diff --git a/nimble/controller/src/ble_ll_conn_hci.c b/nimble/controller/src/ble_ll_conn_hci.c index c864d30ba..c7543b18b 100644 --- a/nimble/controller/src/ble_ll_conn_hci.c +++ b/nimble/controller/src/ble_ll_conn_hci.c @@ -768,8 +768,6 @@ ble_ll_conn_hci_read_rem_features(uint8_t *cmdbuf) connsm->csmflags.cfbit.pending_hci_rd_features = 1; - os_callout_reset(&connsm->rd_features_timer, 0); - return BLE_ERR_SUCCESS; }