Skip to content

Commit b3379ce

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 b3379ce

File tree

9 files changed

+381
-6
lines changed

9 files changed

+381
-6
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()

tests/bluetooth/tester/src/audio/btp/btp_cap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* SPDX-License-Identifier: Apache-2.0
77
*/
88

9+
int cap_extern_ext_ad_setup(bool prohibit);
10+
911
/* CAP commands */
1012
#define BTP_CAP_READ_SUPPORTED_COMMANDS 0x01
1113
struct btp_cap_read_supported_commands_rp {
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: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ static struct btp_bap_unicast_group *u_group;
2424

2525
extern struct bt_csip_set_coordinator_set_member *btp_csip_set_members[CONFIG_BT_MAX_CONN];
2626

27+
static uint8_t cap_prohibit_setting_up_ext_ad;
28+
2729
static struct bt_bap_stream *stream_unicast_to_bap(struct btp_bap_unicast_stream *stream)
2830
{
2931
return &stream->audio_stream.cap_stream.bap_stream;
@@ -560,12 +562,14 @@ static int cap_broadcast_source_adv_setup(struct btp_bap_broadcast_local_source
560562
base_ad[1].type = BT_DATA_NAME_COMPLETE;
561563
base_ad[1].data_len = sizeof(CONFIG_BT_DEVICE_NAME) - 1;
562564
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);
565+
if (!cap_prohibit_setting_up_ext_ad) {
566+
err = tester_gap_create_adv_instance(&param, BTP_GAP_ADDR_TYPE_IDENTITY, base_ad,
567+
2, NULL, 0, gap_settings);
568+
if (err != 0) {
569+
LOG_DBG("Failed to create extended advertising instance: %d", err);
567570

568-
return -EINVAL;
571+
return -EINVAL;
572+
}
569573
}
570574

571575
err = tester_gap_padv_configure(BT_LE_PER_ADV_PARAM(BT_GAP_PER_ADV_FAST_INT_MIN_2,
@@ -936,3 +940,13 @@ uint8_t tester_unregister_cap(void)
936940
{
937941
return BTP_STATUS_SUCCESS;
938942
}
943+
944+
/* Inhibit creating a new extended advertisement instance in btp_cap_broadcast_source_setup and
945+
* cap_broadcast_source_adv_setup, for profiles such as PBP which sets up its own instance with
946+
* more specialized data in advance of calling btp_cap_broadcast_source_setup.
947+
*/
948+
int cap_extern_ext_ad_setup(bool prohibit)
949+
{
950+
cap_prohibit_setting_up_ext_ad = prohibit;
951+
return 0;
952+
}

0 commit comments

Comments
 (0)