diff --git a/subsys/bluetooth/controller/ll_sw/lll_conn.h b/subsys/bluetooth/controller/ll_sw/lll_conn.h index d416ec9a794..7ea0b7874a1 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_conn.h +++ b/subsys/bluetooth/controller/ll_sw/lll_conn.h @@ -46,6 +46,7 @@ struct lll_conn { uint8_t data_chan_count:6; uint8_t data_chan_sel:1; uint8_t role:1; + uint8_t initiated:1; union { struct { @@ -59,6 +60,7 @@ struct lll_conn { #if defined(CONFIG_BT_PERIPHERAL) struct { uint8_t latency_enabled:1; + uint32_t window_widening_periodic_us; uint32_t window_widening_max_us; uint32_t window_widening_prepare_us; diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c index 8bc4ebe7cef..1c173b6bddb 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c @@ -1331,7 +1331,8 @@ static inline int isr_rx_pdu(struct lll_adv *lll, lll_adv_connect_ind_check(lll, pdu_rx, tx_addr, addr, rx_addr, tgt_addr, devmatch_ok, &rl_idx) && - lll->conn) { + lll->conn && + !lll->conn->initiated) { struct node_rx_ftr *ftr; struct node_rx_pdu *rx; int ret; @@ -1366,6 +1367,8 @@ static inline int isr_rx_pdu(struct lll_adv *lll, ret = lll_stop(lll); LL_ASSERT(!ret); + lll->conn->initiated = 1; + rx = ull_pdu_rx_alloc(); rx->hdr.type = NODE_RX_TYPE_CONNECTION; diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c index 2af0082faa1..821de43c285 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c @@ -25,6 +25,7 @@ #include "lll_vendor.h" #include "lll_clock.h" #include "lll_chan.h" +#include "lll_conn.h" #include "lll_adv_types.h" #include "lll_adv.h" #include "lll_adv_pdu.h" @@ -56,7 +57,9 @@ static inline int isr_rx_pdu(struct lll_adv_aux *lll_aux, uint8_t devmatch_ok, uint8_t devmatch_id, uint8_t irkmatch_ok, uint8_t irkmatch_id, uint8_t rssi_ready); +#if defined(CONFIG_BT_PERIPHERAL) static void isr_tx_connect_rsp(void *param); +#endif /* CONFIG_BT_PERIPHERAL */ static struct pdu_adv *init_connect_rsp_pdu(void) { @@ -103,6 +106,7 @@ static struct pdu_adv *init_connect_rsp_pdu(void) return pdu; } +#if defined(CONFIG_BT_PERIPHERAL) static struct pdu_adv *update_connect_rsp_pdu(struct pdu_adv *pdu_ci) { struct pdu_adv_com_ext_adv *cr_com_hdr; @@ -127,6 +131,7 @@ static struct pdu_adv *update_connect_rsp_pdu(struct pdu_adv *pdu_ci) return pdu_cr; } +#endif /* CONFIG_BT_PERIPHERAL */ int lll_adv_aux_init(void) { @@ -487,7 +492,6 @@ static inline int isr_rx_pdu(struct lll_adv_aux *lll_aux, struct pdu_adv *pdu_adv; struct pdu_adv *pdu_aux; struct pdu_adv *pdu_rx; - struct pdu_adv *pdu_tx; struct lll_adv *lll; uint8_t *tgt_addr; uint8_t tx_addr; @@ -566,13 +570,18 @@ static inline int isr_rx_pdu(struct lll_adv_aux *lll_aux, CONFIG_BT_CTLR_GPIO_PA_OFFSET); #endif /* CONFIG_BT_CTLR_GPIO_PA_PIN */ return 0; + +#if defined(CONFIG_BT_PERIPHERAL) } else if ((pdu_rx->type == PDU_ADV_TYPE_AUX_CONNECT_REQ) && (pdu_rx->len == sizeof(struct pdu_adv_connect_ind)) && lll_adv_connect_ind_check(lll, pdu_rx, tx_addr, addr, rx_addr, tgt_addr, - devmatch_ok, &rl_idx)) { + devmatch_ok, &rl_idx) && + lll->conn && + !lll->conn->initiated) { struct node_rx_ftr *ftr; struct node_rx_pdu *rx; + struct pdu_adv *pdu_tx; if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) { rx = ull_pdu_rx_alloc_peek(4); @@ -637,11 +646,13 @@ static inline int isr_rx_pdu(struct lll_adv_aux *lll_aux, } return 0; +#endif /* CONFIG_BT_PERIPHERAL */ } return -EINVAL; } +#if defined(CONFIG_BT_PERIPHERAL) static void isr_tx_connect_rsp(void *param) { struct node_rx_ftr *ftr; @@ -678,9 +689,12 @@ static void isr_tx_connect_rsp(void *param) /* Stop further LLL radio events */ ret = lll_stop(lll); LL_ASSERT(!ret); + + lll->conn->initiated = 1; } /* Clear radio status and events */ lll_isr_status_reset(); lll_isr_cleanup(lll); } +#endif /* CONFIG_BT_PERIPHERAL */ diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c index 2373fa1b963..f9cb53356b3 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c @@ -768,7 +768,7 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx, if (0) { #if defined(CONFIG_BT_CENTRAL) /* Initiator */ - } else if ((lll->conn) && + } else if (lll->conn && !lll->conn->initiated && isr_scan_init_check(lll, pdu_adv_rx, rl_idx)) { struct lll_conn *lll_conn; struct node_rx_ftr *ftr; @@ -925,6 +925,8 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx, ret = lll_stop(lll); LL_ASSERT(!ret); + lll->conn->initiated = 1; + rx = ull_pdu_rx_alloc(); rx->hdr.type = NODE_RX_TYPE_CONNECTION; diff --git a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_adv.c b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_adv.c index 4f4c9302d22..cc45b4e1dd5 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_adv.c +++ b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_adv.c @@ -896,7 +896,8 @@ static inline int isr_rx_pdu(struct lll_adv *lll, (pdu_rx->len == sizeof(struct pdu_adv_connect_ind)) && isr_rx_ci_check(lll, pdu_adv, pdu_rx, devmatch_ok, &rl_idx) && - lll->conn) { + lll->conn && + !lll->conn->initiated) { struct node_rx_ftr *ftr; struct node_rx_pdu *rx; int ret; @@ -930,6 +931,8 @@ static inline int isr_rx_pdu(struct lll_adv *lll, ret = lll_stop(lll); LL_ASSERT(!ret); + lll->conn->initiated = 1; + rx = ull_pdu_rx_alloc(); rx->hdr.type = NODE_RX_TYPE_CONNECTION; diff --git a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_scan.c b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_scan.c index 238882b5efc..652d709d0e2 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_scan.c +++ b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_scan.c @@ -672,7 +672,7 @@ static inline uint32_t isr_rx_pdu(struct lll_scan *lll, uint8_t devmatch_ok, if (0) { #if defined(CONFIG_BT_CENTRAL) /* Initiator */ - } else if ((lll->conn) && + } else if (lll->conn && !lll->conn->initiated && isr_scan_init_check(lll, pdu_adv_rx, rl_idx)) { struct lll_conn *lll_conn; struct node_rx_ftr *ftr; @@ -829,6 +829,8 @@ static inline uint32_t isr_rx_pdu(struct lll_scan *lll, uint8_t devmatch_ok, ret = lll_stop(lll); LL_ASSERT(!ret); + lll->conn->initiated = 1; + rx = ull_pdu_rx_alloc(); rx->hdr.type = NODE_RX_TYPE_CONNECTION; diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv.c b/subsys/bluetooth/controller/ll_sw/ull_adv.c index 4088ec6d2ec..5a84190bfe5 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv.c @@ -872,6 +872,7 @@ uint8_t ll_adv_enable(uint8_t enable) /* FIXME: BEGIN: Move to ULL? */ conn_lll->role = 1; + conn_lll->initiated = 0; conn_lll->data_chan_sel = 0; conn_lll->data_chan_use = 0; conn_lll->event_counter = 0; diff --git a/subsys/bluetooth/controller/ll_sw/ull_master.c b/subsys/bluetooth/controller/ll_sw/ull_master.c index 4c12a2f26dc..94ee0540bbf 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_master.c +++ b/subsys/bluetooth/controller/ll_sw/ull_master.c @@ -213,6 +213,7 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window, conn_lll->data_chan_sel = 0; conn_lll->data_chan_use = 0; conn_lll->role = 0; + conn_lll->initiated = 0; /* FIXME: END: Move to ULL? */ #if defined(CONFIG_BT_CTLR_CONN_META) memset(&conn_lll->conn_meta, 0, sizeof(conn_lll->conn_meta));