Skip to content

Commit 43360df

Browse files
committed
Tests: Bluetooth: Tester: Add support for PBP testing
Adds support for the existing BTP commands for PBP testing. This should enable bttester to be used to test this profile with AutoPTS. Signed-off-by: Frode van der Meeren <[email protected]>
1 parent 1aa2f9d commit 43360df

File tree

8 files changed

+385
-23
lines changed

8 files changed

+385
-23
lines changed

tests/bluetooth/tester/overlay-le-audio.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,6 @@ CONFIG_BT_TBS_SUPPORTED_FEATURES=3
147147

148148
# TMAP
149149
CONFIG_BT_TMAP=y
150+
151+
# PBP
152+
CONFIG_BT_PBP=y

tests/bluetooth/tester/src/audio/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ endif()
6767
if(CONFIG_BT_TMAP)
6868
target_sources(app PRIVATE btp_tmap.c)
6969
endif()
70+
71+
if(CONFIG_BT_PBP)
72+
target_sources(app PRIVATE btp_pbp.c)
73+
endif()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* btp_pbp.c - Bluetooth PBP Tester */
2+
3+
/*
4+
* Copyright (c) 2025 Nordic Semiconductor ASA
5+
*
6+
* SPDX-License-Identifier: Apache-2.0
7+
*/
8+
9+
/* This is main.h */
10+
11+
#define BTP_PBP_READ_SUPPORTED_COMMANDS 0x01
12+
struct btp_pbp_read_supported_commands_rp {
13+
uint8_t data[0];
14+
} __packed;
15+
16+
#define BTP_PBP_SET_PUBLIC_BROADCAST_ANNOUNCEMENT 0x02
17+
struct btp_pbp_set_public_broadcast_announcement_cmd {
18+
uint8_t features;
19+
uint8_t metadata_len;
20+
uint8_t metadata[];
21+
} __packed;
22+
23+
#define BTP_PBP_SET_BROADCAST_NAME 0x03
24+
struct btp_pbp_set_broadcast_name_cmd {
25+
uint8_t name_len;
26+
uint8_t name[];
27+
} __packed;
28+
29+
#define BTP_PBP_BROADCAST_SCAN_START 0x04
30+
struct btp_pbp_broadcast_scan_start_cmd {
31+
} __packed;
32+
33+
#define BTP_PBP_BROADCAST_SCAN_STOP 0x05
34+
struct btp_pbp_broadcast_scan_stop_cmd {
35+
} __packed;
36+
37+
#define BTP_PBP_EV_PUBLIC_BROADCAST_ANOUNCEMENT_FOUND 0x80
38+
struct btp_pbp_ev_public_broadcast_anouncement_found_rp {
39+
bt_addr_le_t address;
40+
uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
41+
uint8_t advertiser_sid;
42+
uint16_t padv_interval;
43+
uint8_t pba_features;
44+
uint8_t broadcast_name_len;
45+
uint8_t broadcast_name[];
46+
} __packed;

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

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -542,30 +542,33 @@ static int cap_broadcast_source_adv_setup(struct btp_bap_broadcast_local_source
542542
struct bt_data base_ad[2];
543543
struct bt_data per_ad;
544544

545-
err = bt_cap_initiator_broadcast_get_id(source->cap_broadcast, &source->broadcast_id);
546-
if (err != 0) {
547-
LOG_DBG("Unable to get broadcast ID: %d", err);
548-
549-
return -EINVAL;
550-
}
545+
if (tester_gap_ext_adv_get() == NULL) {
546+
err = bt_cap_initiator_broadcast_get_id(source->cap_broadcast, &source->broadcast_id);
547+
if (err != 0) {
548+
LOG_DBG("Unable to get broadcast ID: %d", err);
551549

552-
*gap_settings = BIT(BTP_GAP_SETTINGS_DISCOVERABLE) |
553-
BIT(BTP_GAP_SETTINGS_EXTENDED_ADVERTISING);
554-
/* Setup extended advertising data */
555-
net_buf_simple_add_le16(&ad_buf, BT_UUID_BROADCAST_AUDIO_VAL);
556-
net_buf_simple_add_le24(&ad_buf, source->broadcast_id);
557-
base_ad[0].type = BT_DATA_SVC_DATA16;
558-
base_ad[0].data_len = ad_buf.len;
559-
base_ad[0].data = ad_buf.data;
560-
base_ad[1].type = BT_DATA_NAME_COMPLETE;
561-
base_ad[1].data_len = sizeof(CONFIG_BT_DEVICE_NAME) - 1;
562-
base_ad[1].data = CONFIG_BT_DEVICE_NAME;
563-
err = tester_gap_create_adv_instance(&param, BTP_GAP_ADDR_TYPE_IDENTITY, base_ad, 2, NULL,
564-
0, gap_settings);
565-
if (err != 0) {
566-
LOG_DBG("Failed to create extended advertising instance: %d", err);
550+
return -EINVAL;
551+
}
567552

568-
return -EINVAL;
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+
565+
err = tester_gap_create_adv_instance(&param, BTP_GAP_ADDR_TYPE_IDENTITY, base_ad,
566+
2, NULL, 0, gap_settings);
567+
if (err != 0) {
568+
LOG_DBG("Failed to create extended advertising instance: %d", err);
569+
570+
return -EINVAL;
571+
}
569572
}
570573

571574
err = tester_gap_padv_configure(BT_LE_PER_ADV_PARAM(BT_GAP_PER_ADV_FAST_INT_MIN_2,

0 commit comments

Comments
 (0)