@@ -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 }
0 commit comments