Skip to content

Commit b36a0ee

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Fix private address update in auxiliary PDUs
Fix missing implementation to update private resolvable address in auxiliary PDUs on RPA timeout. Without the implementation the controller asserted on RPA timeout when AdvA is not present in the primary channel PDU of Extended Advertising set. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent d54f3bd commit b36a0ee

File tree

1 file changed

+90
-12
lines changed

1 file changed

+90
-12
lines changed

subsys/bluetooth/controller/ll_sw/ull_filter.c

Lines changed: 90 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -777,12 +777,15 @@ void ull_filter_rpa_update(bool timeout)
777777

778778
if (timeout) {
779779
#if defined(CONFIG_BT_BROADCASTER)
780-
struct ll_adv_set *adv;
780+
uint8_t handle;
781781

782-
/* TODO: foreach adv set */
783-
adv = ull_adv_is_enabled_get(0);
784-
if (adv) {
785-
rpa_adv_refresh(adv);
782+
for (handle = 0U; handle < BT_CTLR_ADV_SET; handle++) {
783+
struct ll_adv_set *adv;
784+
785+
adv = ull_adv_is_enabled_get(handle);
786+
if (adv) {
787+
rpa_adv_refresh(adv);
788+
}
786789
}
787790
#endif
788791
}
@@ -1131,26 +1134,101 @@ static void rl_update(void)
11311134
#if defined(CONFIG_BT_BROADCASTER)
11321135
static void rpa_adv_refresh(struct ll_adv_set *adv)
11331136
{
1137+
struct lll_adv_aux *lll_aux;
11341138
struct pdu_adv *prev;
1139+
struct lll_adv *lll;
11351140
struct pdu_adv *pdu;
1136-
uint8_t idx;
1141+
uint8_t pri_idx;
1142+
1143+
#if defined(CONFIG_BT_CTLR_ADV_EXT)
1144+
uint8_t sec_idx;
1145+
#endif /* CONFIG_BT_CTLR_ADV_EXT */
11371146

11381147
if (adv->own_addr_type != BT_ADDR_LE_PUBLIC_ID &&
11391148
adv->own_addr_type != BT_ADDR_LE_RANDOM_ID) {
11401149
return;
11411150
}
11421151

1143-
if (adv->lll.rl_idx >= ARRAY_SIZE(rl)) {
1152+
lll = &adv->lll;
1153+
if (lll->rl_idx >= ARRAY_SIZE(rl)) {
11441154
return;
11451155
}
11461156

1147-
prev = lll_adv_data_peek(&adv->lll);
1148-
pdu = lll_adv_data_alloc(&adv->lll, &idx);
11491157

1150-
(void)memcpy(pdu, prev, PDU_AC_LL_HEADER_SIZE + prev->len);
1151-
ull_adv_pdu_update_addrs(adv, pdu);
1158+
pri_idx = UINT8_MAX;
1159+
lll_aux = NULL;
1160+
pdu = NULL;
1161+
prev = lll_adv_data_peek(lll);
1162+
1163+
if (false) {
1164+
1165+
#if defined(CONFIG_BT_CTLR_ADV_EXT)
1166+
} else if (prev->type == PDU_ADV_TYPE_EXT_IND) {
1167+
struct pdu_adv_com_ext_adv *pri_com_hdr;
1168+
struct pdu_adv_ext_hdr pri_hdr_flags;
1169+
struct pdu_adv_ext_hdr *pri_hdr;
1170+
1171+
/* Pick the primary PDU header flags */
1172+
pri_com_hdr = (void *)&prev->adv_ext_ind;
1173+
pri_hdr = (void *)pri_com_hdr->ext_hdr_adv_data;
1174+
if (pri_com_hdr->ext_hdr_len) {
1175+
pri_hdr_flags = *pri_hdr;
1176+
} else {
1177+
*(uint8_t *)&pri_hdr_flags = 0U;
1178+
}
1179+
1180+
/* AdvA, in primary or auxiliary PDU */
1181+
if (pri_hdr_flags.adv_addr) {
1182+
pdu = lll_adv_data_alloc(lll, &pri_idx);
1183+
(void)memcpy(pdu, prev, (PDU_AC_LL_HEADER_SIZE +
1184+
prev->len));
1185+
1186+
#if (CONFIG_BT_CTLR_ADV_AUX_SET > 0)
1187+
} else if (pri_hdr_flags.aux_ptr) {
1188+
struct pdu_adv_com_ext_adv *sec_com_hdr;
1189+
struct pdu_adv_ext_hdr sec_hdr_flags;
1190+
struct pdu_adv_ext_hdr *sec_hdr;
1191+
struct pdu_adv *sec_pdu;
1192+
1193+
lll_aux = lll->aux;
1194+
sec_pdu = lll_adv_aux_data_peek(lll_aux);
1195+
1196+
sec_com_hdr = (void *)&sec_pdu->adv_ext_ind;
1197+
sec_hdr = (void *)sec_com_hdr->ext_hdr_adv_data;
1198+
if (sec_com_hdr->ext_hdr_len) {
1199+
sec_hdr_flags = *sec_hdr;
1200+
} else {
1201+
*(uint8_t *)&sec_hdr_flags = 0U;
1202+
}
1203+
1204+
if (sec_hdr_flags.adv_addr) {
1205+
pdu = lll_adv_aux_data_alloc(lll_aux, &sec_idx);
1206+
(void)memcpy(pdu, sec_pdu,
1207+
(PDU_AC_LL_HEADER_SIZE +
1208+
sec_pdu->len));
1209+
}
1210+
#endif /* (CONFIG_BT_CTLR_ADV_AUX_SET > 0) */
1211+
}
1212+
#endif /* CONFIG_BT_CTLR_ADV_EXT */
1213+
1214+
} else {
1215+
pdu = lll_adv_data_alloc(lll, &pri_idx);
1216+
(void)memcpy(pdu, prev, (PDU_AC_LL_HEADER_SIZE + prev->len));
1217+
}
1218+
1219+
if (pdu) {
1220+
ull_adv_pdu_update_addrs(adv, pdu);
1221+
1222+
if (pri_idx != UINT8_MAX) {
1223+
lll_adv_data_enqueue(lll, pri_idx);
1224+
1225+
#if defined(CONFIG_BT_CTLR_ADV_EXT)
1226+
} else {
1227+
lll_adv_aux_data_enqueue(lll_aux, sec_idx);
1228+
#endif /* CONFIG_BT_CTLR_ADV_EXT */
11521229

1153-
lll_adv_data_enqueue(&adv->lll, idx);
1230+
}
1231+
}
11541232
}
11551233
#endif /* CONFIG_BT_BROADCASTER */
11561234

0 commit comments

Comments
 (0)