@@ -533,40 +533,37 @@ static int cap_broadcast_source_adv_setup(struct btp_bap_broadcast_local_source
533533 uint32_t * gap_settings )
534534{
535535 int err ;
536- struct bt_le_adv_param param = * BT_LE_EXT_ADV_NCONN ;
537- uint32_t broadcast_id ;
538536
539- NET_BUF_SIMPLE_DEFINE (ad_buf , BT_UUID_SIZE_16 + BT_AUDIO_BROADCAST_ID_SIZE );
540537 NET_BUF_SIMPLE_DEFINE (base_buf , 128 );
541538
542539 /* Broadcast Audio Streaming Endpoint advertising data */
543- struct bt_data base_ad [2 ];
544540 struct bt_data per_ad ;
545541
546- err = bt_rand (& broadcast_id , BT_AUDIO_BROADCAST_ID_SIZE );
547- if (err ) {
548- printk ("Unable to generate broadcast ID: %d\n" , err );
549-
550- return - EINVAL ;
551- }
552-
553- * gap_settings = BIT (BTP_GAP_SETTINGS_DISCOVERABLE ) |
554- BIT (BTP_GAP_SETTINGS_EXTENDED_ADVERTISING );
555- /* Setup extended advertising data */
556- net_buf_simple_add_le16 (& ad_buf , BT_UUID_BROADCAST_AUDIO_VAL );
557- net_buf_simple_add_le24 (& ad_buf , source -> broadcast_id );
558- base_ad [0 ].type = BT_DATA_SVC_DATA16 ;
559- base_ad [0 ].data_len = ad_buf .len ;
560- base_ad [0 ].data = ad_buf .data ;
561- base_ad [1 ].type = BT_DATA_NAME_COMPLETE ;
562- base_ad [1 ].data_len = sizeof (CONFIG_BT_DEVICE_NAME ) - 1 ;
563- base_ad [1 ].data = CONFIG_BT_DEVICE_NAME ;
564- err = tester_gap_create_adv_instance (& param , BTP_GAP_ADDR_TYPE_IDENTITY , base_ad , 2 , NULL ,
565- 0 , gap_settings );
566- if (err != 0 ) {
567- LOG_DBG ("Failed to create extended advertising instance: %d" , err );
568-
569- return - EINVAL ;
542+ /* A more specialized adv instance may already have been created by another btp module */
543+ if (tester_gap_ext_adv_get () == NULL ) {
544+ struct bt_le_adv_param param = * BT_LE_EXT_ADV_NCONN ;
545+ struct bt_data base_ad [2 ];
546+
547+ NET_BUF_SIMPLE_DEFINE (ad_buf , BT_UUID_SIZE_16 + BT_AUDIO_BROADCAST_ID_SIZE );
548+ * gap_settings = BIT (BTP_GAP_SETTINGS_DISCOVERABLE ) |
549+ BIT (BTP_GAP_SETTINGS_EXTENDED_ADVERTISING );
550+ /* Setup extended advertising data */
551+ net_buf_simple_add_le16 (& ad_buf , BT_UUID_BROADCAST_AUDIO_VAL );
552+ net_buf_simple_add_le24 (& ad_buf , source -> broadcast_id );
553+ base_ad [0 ].type = BT_DATA_SVC_DATA16 ;
554+ base_ad [0 ].data_len = ad_buf .len ;
555+ base_ad [0 ].data = ad_buf .data ;
556+ base_ad [1 ].type = BT_DATA_NAME_COMPLETE ;
557+ base_ad [1 ].data_len = sizeof (CONFIG_BT_DEVICE_NAME ) - 1 ;
558+ base_ad [1 ].data = CONFIG_BT_DEVICE_NAME ;
559+
560+ err = tester_gap_create_adv_instance (& param , BTP_GAP_ADDR_TYPE_IDENTITY , base_ad ,
561+ 2 , NULL , 0 , gap_settings );
562+ if (err != 0 ) {
563+ LOG_DBG ("Failed to create extended advertising instance: %d" , err );
564+
565+ return - EINVAL ;
566+ }
570567 }
571568
572569 err = tester_gap_padv_configure (BT_LE_PER_ADV_PARAM (BT_GAP_PER_ADV_FAST_INT_MIN_2 ,
0 commit comments