Skip to content

Commit 6af9a43

Browse files
cvinayakcfriedt
authored andcommitted
Bluetooth: controller: Fix populate offset in latest advertising PDU
Fix implementation to populate the aux, and sync offset in the latest PDU. If both the current and latest of the double buffer has been filled and LLL did not pick the latest PDU, then the offset should be filled into the latest PDU (and not into the first/current PDU). Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 3ce9b2f commit 6af9a43

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ static inline struct pdu_adv *lll_adv_scan_rsp_peek(struct lll_adv *lll)
6565
return (void *)lll->scan_rsp.pdu[lll->scan_rsp.last];
6666
}
6767

68+
static inline struct pdu_adv *
69+
lll_adv_pdu_latest_peek(const struct lll_adv_pdu *const pdu)
70+
{
71+
uint8_t first;
72+
73+
first = pdu->first;
74+
if (first != pdu->last) {
75+
first += 1U;
76+
if (first == DOUBLE_BUFFER_SIZE) {
77+
first = 0U;
78+
}
79+
}
80+
81+
return (void *)pdu->pdu[first];
82+
}
83+
84+
static inline struct pdu_adv *
85+
lll_adv_data_latest_peek(const struct lll_adv *const lll)
86+
{
87+
return lll_adv_pdu_latest_peek(&lll->adv_data);
88+
}
89+
6890
#if defined(CONFIG_BT_CTLR_ADV_EXT)
6991
static inline struct pdu_adv *lll_adv_aux_data_alloc(struct lll_adv_aux *lll,
7092
uint8_t *idx)
@@ -83,6 +105,12 @@ static inline struct pdu_adv *lll_adv_aux_data_peek(struct lll_adv_aux *lll)
83105
return (void *)lll->data.pdu[lll->data.last];
84106
}
85107

108+
static inline struct pdu_adv *
109+
lll_adv_aux_data_latest_peek(const struct lll_adv_aux *const lll)
110+
{
111+
return lll_adv_pdu_latest_peek(&lll->data);
112+
}
113+
86114
static inline struct pdu_adv *lll_adv_aux_data_curr_get(struct lll_adv_aux *lll)
87115
{
88116
return (void *)lll->data.pdu[lll->data.first];
@@ -139,6 +167,12 @@ static inline struct pdu_adv *lll_adv_sync_data_peek(struct lll_adv_sync *lll,
139167
return (void *)lll->data.pdu[last];
140168
}
141169

170+
static inline struct pdu_adv *
171+
lll_adv_sync_data_latest_peek(const struct lll_adv_sync *const lll)
172+
{
173+
return lll_adv_pdu_latest_peek(&lll->data);
174+
}
175+
142176
#if defined(CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY)
143177
static inline void *lll_adv_sync_extra_data_peek(struct lll_adv_sync *lll)
144178
{

subsys/bluetooth/controller/ll_sw/ull_adv_sync.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ static void mfy_sync_offset_get(void *param)
15451545
*/
15461546
lll_sync->ticks_offset = ticks_to_expire + 1;
15471547

1548-
pdu = lll_adv_aux_data_curr_get(adv->lll.aux);
1548+
pdu = lll_adv_aux_data_latest_peek(adv->lll.aux);
15491549
si = sync_info_get(pdu);
15501550
sync_info_offset_fill(si, ticks_to_expire, 0);
15511551
si->evt_cntr = lll_sync->event_counter + lll_sync->latency_prepare +

0 commit comments

Comments
 (0)