Skip to content

Commit a5fa9d1

Browse files
nimble/ll: Add option to select location of AdvA in ext adv
This adds syscfg to select location of AdvA in extended advertising PDUs. If enabled, AdvA is put in AUX_ADV_IND instead of ADV_EXT_IND. This is enabled by default to retain current behavior.
1 parent caad037 commit a5fa9d1

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

nimble/controller/src/ble_ll_adv.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ ble_ll_adv_pdu_make(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
570570
uint8_t ext_hdr_len;
571571
uint8_t ext_hdr_flags;
572572
uint32_t offset;
573+
bool has_adva;
573574

574575
advsm = pducb_arg;
575576

@@ -581,8 +582,6 @@ ble_ll_adv_pdu_make(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
581582
/* only ADV_EXT_IND goes on primary advertising channels */
582583
pdu_type = BLE_ADV_PDU_TYPE_ADV_EXT_IND;
583584

584-
*hdr_byte = pdu_type;
585-
586585
adv_mode = 0;
587586
if (advsm->props & BLE_HCI_LE_SET_EXT_ADV_PROP_CONNECTABLE) {
588587
adv_mode |= BLE_LL_EXT_ADV_MODE_CONN;
@@ -591,11 +590,19 @@ ble_ll_adv_pdu_make(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
591590
adv_mode |= BLE_LL_EXT_ADV_MODE_SCAN;
592591
}
593592

593+
has_adva = !MYNEWT_VAL(BLE_LL_EXT_ADV_ADVA_IN_AUX) &&
594+
!(advsm->props & BLE_HCI_LE_SET_EXT_ADV_PROP_ANON_ADV);
595+
594596
ext_hdr_len = BLE_LL_EXT_ADV_FLAGS_SIZE + BLE_LL_EXT_ADV_DATA_INFO_SIZE +
595597
BLE_LL_EXT_ADV_AUX_PTR_SIZE;
596598
ext_hdr_flags = (1 << BLE_LL_EXT_ADV_DATA_INFO_BIT) |
597599
(1 << BLE_LL_EXT_ADV_AUX_PTR_BIT);
598600

601+
if (has_adva) {
602+
ext_hdr_len += BLE_LL_EXT_ADV_ADVA_SIZE;
603+
ext_hdr_flags |= (1 << BLE_LL_EXT_ADV_ADVA_BIT);
604+
}
605+
599606
/* ext hdr len and adv mode */
600607
dptr[0] = ext_hdr_len | (adv_mode << 6);
601608
dptr += 1;
@@ -604,6 +611,15 @@ ble_ll_adv_pdu_make(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
604611
dptr[0] = ext_hdr_flags;
605612
dptr += 1;
606613

614+
if (has_adva) {
615+
/* AdvA */
616+
if (advsm->flags & BLE_LL_ADV_SM_FLAG_TX_ADD) {
617+
pdu_type |= BLE_ADV_PDU_HDR_TXADD_RAND;
618+
}
619+
memcpy(dptr, advsm->adva, BLE_LL_EXT_ADV_ADVA_SIZE);
620+
dptr += BLE_LL_EXT_ADV_ADVA_SIZE;
621+
}
622+
607623
/* ADI */
608624
dptr[0] = advsm->adi & 0x00ff;
609625
dptr[1] = advsm->adi >> 8;
@@ -619,6 +635,8 @@ ble_ll_adv_pdu_make(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
619635
ble_ll_adv_put_aux_ptr(AUX_CURRENT(advsm)->chan, advsm->sec_phy,
620636
offset, dptr);
621637

638+
*hdr_byte = pdu_type;
639+
622640
return BLE_LL_EXT_ADV_HDR_LEN + ext_hdr_len;
623641
}
624642

@@ -1407,9 +1425,16 @@ ble_ll_adv_aux_calculate_payload(struct ble_ll_adv_sm *advsm, uint16_t props,
14071425
ext_hdr_len += BLE_LL_EXT_ADV_DATA_INFO_SIZE;
14081426
}
14091427

1410-
/* AdvA in 1st PDU, except for anonymous */
1428+
/* AdvA if:
1429+
* - 1st PDU
1430+
* - not anonymous
1431+
* - scannable/connectable or ADVA_IN_AUX selected
1432+
*/
14111433
if (first_pdu &&
1412-
!(props & BLE_HCI_LE_SET_EXT_ADV_PROP_ANON_ADV)) {
1434+
!(props & BLE_HCI_LE_SET_EXT_ADV_PROP_ANON_ADV) &&
1435+
((props & (BLE_HCI_LE_SET_EXT_ADV_PROP_CONNECTABLE |
1436+
BLE_HCI_LE_SET_EXT_ADV_PROP_SCANNABLE)) ||
1437+
MYNEWT_VAL(BLE_LL_EXT_ADV_ADVA_IN_AUX))) {
14131438
ext_hdr_flags |= (1 << BLE_LL_EXT_ADV_ADVA_BIT);
14141439
ext_hdr_len += BLE_LL_EXT_ADV_ADVA_SIZE;
14151440
}

nimble/controller/syscfg.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,11 @@ syscfg.defs:
618618
like build optimisation, cache, clock speed etc.
619619
value: 0
620620

621+
BLE_LL_EXT_ADV_ADVA_IN_AUX:
622+
description: >
623+
Put AdvA in AUX_ADV_IND instead of ADV_EXT_IND.
624+
value: 1
625+
621626
BLE_LL_STACK_SIZE:
622627
description: >
623628
This is the stack size for LL task.

0 commit comments

Comments
 (0)