Skip to content

Commit 6f2d4a4

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: controller: Fixes and use of defines related to initiator
Fixed incorrect LLL context used to generate done event for auxiliary channel scanning. Other minor comments and fixes. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 031aa8c commit 6f2d4a4

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,17 @@ void lll_scan_prepare_connect_req(struct lll_scan *lll, struct pdu_adv *pdu_tx,
153153
* 1.25ms for a legacy PDU, 2.5ms for an LE Uncoded PHY and 3.75ms for
154154
* an LE Coded PHY.
155155
*/
156-
switch (phy) {
157-
case PHY_LEGACY:
158-
conn_offset_us += 1250;
159-
break;
156+
if (0) {
160157
#if defined(CONFIG_BT_CTLR_ADV_EXT)
161-
case PHY_1M:
162-
case PHY_2M:
163-
conn_offset_us += 2500;
164-
break;
165-
#if defined(CONFIG_BT_CTLR_PHY_CODED)
166-
case PHY_CODED:
167-
conn_offset_us += 3750;
168-
break;
169-
#endif /* CONFIG_BT_CTLR_PHY_CODED */
170-
#endif /* CONFIG_BT_CTLR_ADV_EXT */
171-
default:
172-
LL_ASSERT(0);
173-
break;
158+
} else if (phy) {
159+
if (phy & PHY_CODED) {
160+
conn_offset_us += WIN_DELAY_CODED;
161+
} else {
162+
conn_offset_us += WIN_DELAY_UNCODED;
163+
}
164+
#endif
165+
} else {
166+
conn_offset_us += WIN_DELAY_LEGACY;
174167
}
175168

176169
if (!IS_ENABLED(CONFIG_BT_CTLR_SCHED_ADVANCED) ||

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,6 @@ static int isr_rx_pdu(struct lll_scan_aux *lll, uint8_t devmatch_ok,
354354
struct lll_scan *lll_scan;
355355
struct pdu_adv *pdu;
356356

357-
#if defined(CONFIG_BT_CENTRAL)
358-
/* AUX_CONNECT_REQ is the same as CONNECT_IND */
359-
const uint8_t aux_connect_req_len = sizeof(struct pdu_adv_connect_ind);
360-
/* AUX_CONNECT_RSP has only AdvA and TargetA in extended header */
361-
const uint8_t aux_connect_rsp_len = PDU_AC_EXT_HEADER_SIZE_MIN +
362-
sizeof(struct pdu_adv_ext_hdr) +
363-
ADVA_SIZE + TARGETA_SIZE;
364-
#endif
365-
366357
node_rx = ull_pdu_rx_alloc_peek(3);
367358
if (!node_rx) {
368359
return -ENOBUFS;
@@ -413,6 +404,17 @@ static int isr_rx_pdu(struct lll_scan_aux *lll, uint8_t devmatch_ok,
413404
pdu_end_us %= scan_interval_us;
414405
}
415406

407+
/* AUX_CONNECT_REQ is the same as CONNECT_IND */
408+
const uint8_t aux_connect_req_len =
409+
sizeof(struct pdu_adv_connect_ind);
410+
/* AUX_CONNECT_RSP has only AdvA and TargetA in extended common
411+
* header
412+
*/
413+
const uint8_t aux_connect_rsp_len =
414+
PDU_AC_EXT_HEADER_SIZE_MIN +
415+
sizeof(struct pdu_adv_ext_hdr) +
416+
ADVA_SIZE + TARGETA_SIZE;
417+
416418
ull = HDR_LLL2ULL(lll_scan);
417419
if (pdu_end_us > (HAL_TICKER_TICKS_TO_US(ull->ticks_slot) -
418420
EVENT_IFS_US -
@@ -460,7 +462,7 @@ static int isr_rx_pdu(struct lll_scan_aux *lll, uint8_t devmatch_ok,
460462
radio_tmr_end_capture();
461463

462464
radio_tmr_tifs_set(EVENT_IFS_US);
463-
radio_switch_complete_and_rx(PHY_1M);
465+
radio_switch_complete_and_rx(lll->phy);
464466
radio_isr_set(isr_tx_connect_req, lll);
465467

466468
#if defined(CONFIG_BT_CTLR_GPIO_PA_PIN)
@@ -678,7 +680,7 @@ static void isr_rx_connect_rsp(void *param)
678680
ull_rx_put(rx->hdr.link, rx);
679681
ull_rx_sched();
680682

681-
radio_isr_set(isr_done, lll);
683+
radio_isr_set(isr_done, lll_aux);
682684
radio_disable();
683685
}
684686
#endif /* CONFIG_BT_CENTRAL */

subsys/bluetooth/controller/ll_sw/ull_scan.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ uint8_t ll_scan_params_set(uint8_t type, uint16_t interval, uint16_t window,
100100

101101
lll = &scan->lll;
102102

103+
/* NOTE: Pass invalid interval value to not start scanning using this
104+
* scan instance.
105+
*/
103106
if (!interval) {
107+
/* Set PHY to 0 to not start scanning on this instance */
104108
lll->phy = 0U;
105109

106110
return 0;

subsys/bluetooth/controller/ll_sw/ull_slave.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,14 @@ void ull_slave_setup(memq_link_t *link, struct node_rx_hdr *rx,
169169
win_offset = sys_le16_to_cpu(pdu_adv->connect_ind.win_offset);
170170
conn_interval_us = lll->interval * CONN_INT_UNIT_US;
171171

172+
/* transmitWindowDelay to default calculated connection offset:
173+
* 1.25ms for a legacy PDU, 2.5ms for an LE Uncoded PHY and 3.75ms for
174+
* an LE Coded PHY.
175+
*/
172176
if (0) {
173177
#if defined(CONFIG_BT_CTLR_ADV_EXT)
174178
} else if (adv->lll.aux) {
175-
if (adv->lll.phy_s & BIT(2)) {
179+
if (adv->lll.phy_s & PHY_CODED) {
176180
win_delay_us = WIN_DELAY_CODED;
177181
} else {
178182
win_delay_us = WIN_DELAY_UNCODED;

0 commit comments

Comments
 (0)