Skip to content

Commit 220170a

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Fix Periodic Advertising time reservation
Fix Periodic Advertising time reservation when enabling with ADI support. As the PDU is updated, use the updated PDU to calculate the time reservation. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 1ed9bda commit 220170a

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ static inline void lll_adv_sync_data_enqueue(struct lll_adv_sync *lll,
172172
lll_adv_pdu_enqueue(&lll->data, idx);
173173
}
174174

175-
static inline struct pdu_adv *lll_adv_sync_data_peek(struct lll_adv_sync *lll,
176-
void **extra_data)
175+
static inline struct pdu_adv *
176+
lll_adv_sync_data_peek(const struct lll_adv_sync *lll, void **extra_data)
177177
{
178178
uint8_t last = lll->data.last;
179179

subsys/bluetooth/controller/ll_sw/ull_adv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ uint8_t ll_adv_enable(uint8_t enable)
15111511
EVENT_OVERHEAD_START_US +
15121512
(EVENT_TICKER_RES_MARGIN_US << 1));
15131513

1514-
ticks_slot_overhead = ull_adv_sync_evt_init(adv, sync);
1514+
ticks_slot_overhead = ull_adv_sync_evt_init(adv, sync, NULL);
15151515
ret = ull_adv_sync_start(adv, sync,
15161516
ticks_anchor_sync,
15171517
ticks_slot_overhead);

subsys/bluetooth/controller/ll_sw/ull_adv_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ uint32_t ull_adv_sync_time_get(const struct ll_adv_sync_set *sync,
231231

232232
/* helper function to calculate ticks_slot and return slot overhead */
233233
uint32_t ull_adv_sync_evt_init(struct ll_adv_set *adv,
234-
struct ll_adv_sync_set *sync);
234+
struct ll_adv_sync_set *sync,
235+
struct pdu_adv *pdu);
235236

236237
/* helper function to start periodic advertising */
237238
uint32_t ull_adv_sync_start(struct ll_adv_set *adv,

subsys/bluetooth/controller/ll_sw/ull_adv_sync.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,7 @@ uint8_t ll_adv_sync_ad_data_set(uint8_t handle, uint8_t op, uint8_t len,
683683

684684
uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
685685
{
686-
void *extra_data_prev, *extra_data;
687-
struct pdu_adv *pdu_prev, *pdu;
686+
struct pdu_adv *ter_pdu = NULL;
688687
struct lll_adv_sync *lll_sync;
689688
struct ll_adv_sync_set *sync;
690689
uint8_t sync_got_enabled;
@@ -761,6 +760,8 @@ uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
761760
if (IS_ENABLED(CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT)) {
762761
uint8_t hdr_data[ULL_ADV_HDR_DATA_LEN_SIZE +
763762
ULL_ADV_HDR_DATA_ADI_PTR_SIZE] = {0, };
763+
void *extra_data_prev, *extra_data;
764+
struct pdu_adv *pdu_prev, *pdu;
764765
uint16_t hdr_add_fields;
765766
uint16_t hdr_rem_fields;
766767

@@ -779,6 +780,9 @@ uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
779780
return err;
780781
}
781782

783+
/* Use PDU to calculate time reservation */
784+
ter_pdu = pdu;
785+
782786
#if defined(CONFIG_BT_CTLR_DF_ADV_CTE_TX)
783787
if (extra_data) {
784788
ull_adv_sync_extra_data_set_clear(extra_data_prev,
@@ -863,7 +867,7 @@ uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
863867
ull_adv_sync_info_fill(sync, sync_info);
864868

865869
/* Calculate the ticks_slot and return slot overhead */
866-
ticks_slot_overhead = ull_adv_sync_evt_init(adv, sync);
870+
ticks_slot_overhead = ull_adv_sync_evt_init(adv, sync, ter_pdu);
867871

868872
/* If Auxiliary PDU already active, find and schedule Periodic
869873
* advertising follow it.
@@ -1075,20 +1079,20 @@ uint32_t ull_adv_sync_time_get(const struct ll_adv_sync_set *sync,
10751079
}
10761080

10771081
uint32_t ull_adv_sync_evt_init(struct ll_adv_set *adv,
1078-
struct ll_adv_sync_set *sync)
1082+
struct ll_adv_sync_set *sync,
1083+
struct pdu_adv *pdu)
10791084
{
1080-
struct lll_adv_sync *lll_sync;
10811085
uint32_t ticks_slot_overhead;
10821086
uint32_t ticks_slot_offset;
1083-
struct pdu_adv *ter_pdu;
10841087
uint32_t time_us;
10851088

10861089
ull_hdr_init(&sync->ull);
10871090

1088-
lll_sync = &sync->lll;
1089-
ter_pdu = lll_adv_sync_data_peek(lll_sync, NULL);
1091+
if (!pdu) {
1092+
pdu = lll_adv_sync_data_peek(&sync->lll, NULL);
1093+
}
10901094

1091-
time_us = sync_time_get(sync, ter_pdu);
1095+
time_us = sync_time_get(sync, pdu);
10921096

10931097
/* TODO: active_to_start feature port */
10941098
sync->ull.ticks_active_to_start = 0U;

0 commit comments

Comments
 (0)