nimble/ll: Fix error code in read remote feature event
If connection is dropped and read remote feature was in progress let us
send this event before disconnection complete event and with actually
error code and not the fixed one as it was so far.
This should fixed certification test LL/CONN/MAS/BV-19
@@ -2130,6 +2130,15 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
connsm->csmflags.cfbit.pending_hci_rd_features = 0;
}
+ /*
+ * 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);
+ connsm->csmflags.cfbit.pending_hci_rd_features = 0;
+ }
+
/*
* We need to send a disconnection complete event. Connection Complete for
* canceling connection creation is sent from LE Create Connection Cancel
@@ -2143,15 +2152,6 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
ble_ll_disconn_comp_event_send(connsm, 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 */
STAILQ_INSERT_TAIL(&g_ble_ll_conn_free_list, connsm, free_stqe);
