Skip to content

Commit ed92eb5

Browse files
committed
[nrf fromtree] test: bluetooth: tester: Fix regression in PBP
- Allocate source in PBP first time adv is created - Only set_adv_data in adv_setup if ext_adv already exists - Fixes regression in PTS for PBP tests Signed-off-by: Alexander Svensen <[email protected]> (cherry picked from commit 33b4fae) Signed-off-by: Alexander Svensen <[email protected]>
1 parent 5319cfc commit ed92eb5

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

tests/bluetooth/tester/hci_ipc_cpunet.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ CONFIG_BT_CTLR_ISOAL_PSN_IGNORE=y
1010
CONFIG_BT_ISO_MAX_BIG=2
1111
CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
1212

13-
CONFIG_BT_CTLR_ADV_ISO_SET=2
1413
CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=4
1514
CONFIG_BT_CTLR_ADV_ISO_STREAM_MAX=4
1615

tests/bluetooth/tester/src/audio/btp_bap_broadcast.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#define LOG_MODULE_NAME bttester_bap_broadcast
2525
LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL);
2626
#include "btp/btp.h"
27-
#include "btp_bap_audio_stream.h"
2827
#include "btp_bap_broadcast.h"
2928

3029
static K_SEM_DEFINE(sem_stream_stopped, 0U,

tests/bluetooth/tester/src/audio/btp_bap_broadcast.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <zephyr/bluetooth/audio/cap.h>
1010

11+
#include "btp_bap_audio_stream.h"
12+
1113
struct btp_bap_broadcast_stream {
1214
struct btp_bap_audio_stream audio_stream;
1315
struct bt_audio_codec_cfg codec_cfg;

tests/bluetooth/tester/src/audio/btp_pbp.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010

1111
#include <zephyr/bluetooth/audio/bap.h>
1212
#include <zephyr/bluetooth/audio/pbp.h>
13+
#include <zephyr/bluetooth/bluetooth.h>
1314
#include <zephyr/logging/log.h>
1415
#include <zephyr/sys/util.h>
1516
#define LOG_MODULE_NAME bttester_pbp
1617
LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL);
1718

19+
#include "btp_bap_broadcast.h"
20+
1821
#define PBP_EXT_ADV_METADATA_LEN_MAX 128
1922

2023
static uint8_t pbp_features_cached;
@@ -143,7 +146,6 @@ static int pbp_broadcast_source_adv_setup(void)
143146

144147
int err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
145148
struct bt_data ext_ad[3];
146-
struct bt_le_ext_adv *ext_adv = NULL;
147149

148150
if (err) {
149151
LOG_ERR("Unable to generate broadcast ID: %d\n", err);
@@ -166,13 +168,30 @@ static int pbp_broadcast_source_adv_setup(void)
166168
ext_ad[2].data_len = pba_buf.len;
167169
ext_ad[2].data = pba_buf.data;
168170

169-
err = tester_gap_create_adv_instance(&param, BTP_GAP_ADDR_TYPE_IDENTITY, ext_ad,
170-
ARRAY_SIZE(ext_ad), NULL, 0, &gap_settings, &ext_adv);
171-
if (err) {
172-
LOG_ERR("Could not set up extended advertisement: %d", err);
173-
return -EINVAL;
171+
struct btp_bap_broadcast_local_source *source;
172+
173+
source = btp_bap_broadcast_local_source_from_src_id_get(0);
174+
175+
if (source->ext_adv == NULL) {
176+
err = tester_gap_create_adv_instance(&param, BTP_GAP_ADDR_TYPE_IDENTITY, ext_ad,
177+
ARRAY_SIZE(ext_ad), NULL, 0, &gap_settings,
178+
&source->ext_adv);
179+
if (err != 0) {
180+
LOG_ERR("Could not set up extended advertisement: %d", err);
181+
return -EINVAL;
182+
}
183+
} else {
184+
err = bt_le_ext_adv_set_data(source->ext_adv, ext_ad, ARRAY_SIZE(ext_ad), NULL, 0);
185+
186+
if (err != 0) {
187+
LOG_ERR("Could not set extended advertisement data: %d", err);
188+
return -EINVAL;
189+
}
174190
}
175191

192+
source->broadcast_id = broadcast_id;
193+
source->allocated = true;
194+
176195
return 0;
177196
}
178197

0 commit comments

Comments
 (0)