diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c index f61b7b1cd86..eca90b56d5b 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c @@ -592,10 +592,11 @@ static void isr_done(void *param) e->mic_state = mic_state; #endif /* CONFIG_BT_CTLR_LE_ENC */ +#if defined(CONFIG_BT_PERIPHERAL) if (trx_cnt) { struct lll_conn *lll = param; - if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && lll->role) { + if (lll->role) { u32_t preamble_to_addr_us; #if defined(CONFIG_BT_CTLR_PHY) @@ -617,6 +618,7 @@ static void isr_done(void *param) lll->slave.window_size_event_us = 0; } } +#endif /* CONFIG_BT_PERIPHERAL */ isr_cleanup(param); } @@ -655,12 +657,14 @@ static int isr_rx_pdu(struct lll_conn *lll, struct pdu_data *pdu_data_rx, /* Increment serial number */ lll->sn++; +#if defined(CONFIG_BT_PERIPHERAL) /* First ack (and redundantly any other ack) enable use of * slave latency. */ - if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && lll->role) { + if (lll->role) { lll->slave.latency_enabled = 1; } +#endif /* CONFIG_BT_PERIPHERAL */ if (!lll->empty) { struct pdu_data *pdu_data_tx; diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn.c b/subsys/bluetooth/controller/ll_sw/ull_conn.c index 2068c9d4394..85c22c5df26 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn.c @@ -949,7 +949,18 @@ void ull_conn_done(struct node_rx_event_done *done) * Slave received terminate ind or MIC failure */ reason_peer = conn->llcp_terminate.reason_peer; - if (reason_peer && (lll->role || conn->master.terminate_ack)) { + if (reason_peer && ( +#if defined(CONFIG_BT_PERIPHERAL) + lll->role || +#else /* CONFIG_BT_PERIPHERAL */ + 0 || +#endif /* CONFIG_BT_PERIPHERAL */ +#if defined(CONFIG_BT_CENTRAL) + conn->master.terminate_ack +#else /* CONFIG_BT_CENTRAL */ + 1 +#endif /* CONFIG_BT_CENTRAL */ + )) { conn_cleanup(conn, reason_peer); return; @@ -965,7 +976,9 @@ void ull_conn_done(struct node_rx_event_done *done) ticks_drift_plus = 0U; ticks_drift_minus = 0U; if (done->extra.trx_cnt) { - if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && lll->role) { + if (0) { +#if defined(CONFIG_BT_PERIPHERAL) + } else if (lll->role) { ull_slave_done(done, &ticks_drift_plus, &ticks_drift_minus); @@ -976,8 +989,13 @@ void ull_conn_done(struct node_rx_event_done *done) } else if (lll->slave.latency_enabled) { lll->latency_event = lll->latency; } +#endif /* CONFIG_BT_PERIPHERAL */ + +#if defined(CONFIG_BT_CENTRAL) } else if (reason_peer) { conn->master.terminate_ack = 1; +#endif /* CONFIG_BT_CENTRAL */ + } /* Reset connection failed to establish countdown */ @@ -1025,6 +1043,7 @@ void ull_conn_done(struct node_rx_event_done *done) if (conn->supervision_expire <= 6U) { force = 1U; } +#if defined(CONFIG_BT_PERIPHERAL) /* use randomness to force slave role when anchor * points are being missed. */ @@ -1041,6 +1060,7 @@ void ull_conn_done(struct node_rx_event_done *done) } } } +#endif /* CONFIG_BT_PERIPHERAL */ } else { conn_cleanup(conn, BT_HCI_ERR_CONN_TIMEOUT); @@ -2014,10 +2034,10 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, u16_t lazy, ctrl_tx_enqueue(conn, tx); } else if (instant_latency <= 0x7FFF) { + u32_t ticks_win_offset = 0; u32_t ticks_slot_overhead; u16_t conn_interval_old; u16_t conn_interval_new; - u32_t ticks_win_offset; u32_t conn_interval_us; struct node_rx_pdu *rx; u8_t ticker_id_conn; @@ -2118,7 +2138,10 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, u16_t lazy, /* calculate the window widening and interval */ conn_interval_us = conn->llcp.conn_upd.interval * 1250U; periodic_us = conn_interval_us; - if (lll->role) { + + if (0) { +#if defined(CONFIG_BT_PERIPHERAL) + } else if (lll->role) { lll->slave.window_widening_prepare_us -= lll->slave.window_widening_periodic_us * instant_latency; @@ -2149,7 +2172,10 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, u16_t lazy, (conn->llcp.conn_upd.win_offset_us / 1250U) * 1250U); periodic_us -= lll->slave.window_widening_periodic_us; - } else { +#endif /* CONFIG_BT_PERIPHERAL */ + +#if defined(CONFIG_BT_CENTRAL) + } else if (!lll->role) { ticks_win_offset = HAL_TICKER_US_TO_TICKS( conn->llcp.conn_upd.win_offset_us); @@ -2158,7 +2184,12 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, u16_t lazy, * tick so as to use the ceiled value. */ ticks_win_offset += 1U; +#endif /* CONFIG_BT_CENTRAL */ + + } else { + LL_ASSERT(0); } + lll->interval = conn->llcp.conn_upd.interval; lll->latency = conn->llcp.conn_upd.latency; conn->supervision_reload = @@ -3925,11 +3956,13 @@ static inline void reject_ind_conn_upd_recv(struct ll_conn *conn, } /* FIXME: handle unsupported LL parameters error */ else if (rej_ext_ind->error_code != BT_HCI_ERR_LL_PROC_COLLISION) { +#if defined(CONFIG_BT_PERIPHERAL) /* update to next ticks offset */ if (lll->role) { conn->slave.ticks_to_offset = conn->llcp_conn_param.ticks_to_offset_next; } +#endif /* CONFIG_BT_PERIPHERAL */ } if (conn->llcp_conn_param.state == LLCP_CPR_STATE_RSP_WAIT) { diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn_types.h b/subsys/bluetooth/controller/ll_sw/ull_conn_types.h index 47b6a3d8822..c9c355b6a90 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn_types.h +++ b/subsys/bluetooth/controller/ll_sw/ull_conn_types.h @@ -35,6 +35,7 @@ struct ll_conn { u8_t fex_valid:1; } common; +#if defined(CONFIG_BT_PERIPHERAL) struct { u8_t fex_valid:1; u8_t latency_cancel:1; @@ -42,11 +43,14 @@ struct ll_conn { u32_t force; u32_t ticks_to_offset; } slave; +#endif /* CONFIG_BT_PERIPHERAL */ +#if defined(CONFIG_BT_CENTRAL) struct { u8_t fex_valid:1; u8_t terminate_ack:1; } master; +#endif /* CONFIG_BT_CENTRAL */ }; u8_t llcp_req;