Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrf fromtree] tests: bluetooth: tester: Add PBP support #2499

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/bluetooth/tester/overlay-le-audio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,6 @@ CONFIG_BT_TBS_SUPPORTED_FEATURES=3

# TMAP
CONFIG_BT_TMAP=y

# PBP
CONFIG_BT_PBP=y
4 changes: 4 additions & 0 deletions tests/bluetooth/tester/src/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ endif()
if(CONFIG_BT_TMAP)
target_sources(app PRIVATE btp_tmap.c)
endif()

if(CONFIG_BT_PBP)
target_sources(app PRIVATE btp_pbp.c)
endif()
46 changes: 46 additions & 0 deletions tests/bluetooth/tester/src/audio/btp/btp_pbp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* btp_pbp.c - Bluetooth PBP Tester */

/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/* This is main.h */

#define BTP_PBP_READ_SUPPORTED_COMMANDS 0x01
struct btp_pbp_read_supported_commands_rp {
uint8_t data[0];
} __packed;

#define BTP_PBP_SET_PUBLIC_BROADCAST_ANNOUNCEMENT 0x02
struct btp_pbp_set_public_broadcast_announcement_cmd {
uint8_t features;
uint8_t metadata_len;
uint8_t metadata[];
} __packed;

#define BTP_PBP_SET_BROADCAST_NAME 0x03
struct btp_pbp_set_broadcast_name_cmd {
uint8_t name_len;
uint8_t name[];
} __packed;

#define BTP_PBP_BROADCAST_SCAN_START 0x04
struct btp_pbp_broadcast_scan_start_cmd {
} __packed;

#define BTP_PBP_BROADCAST_SCAN_STOP 0x05
struct btp_pbp_broadcast_scan_stop_cmd {
} __packed;

#define BTP_PBP_EV_PUBLIC_BROADCAST_ANOUNCEMENT_FOUND 0x80
struct btp_pbp_ev_public_broadcast_anouncement_found_rp {
bt_addr_le_t address;
uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
uint8_t advertiser_sid;
uint16_t padv_interval;
uint8_t pba_features;
uint8_t broadcast_name_len;
uint8_t broadcast_name[];
} __packed;
53 changes: 25 additions & 28 deletions tests/bluetooth/tester/src/audio/btp_cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,40 +533,37 @@ static int cap_broadcast_source_adv_setup(struct btp_bap_broadcast_local_source
uint32_t *gap_settings)
{
int err;
struct bt_le_adv_param param = *BT_LE_EXT_ADV_NCONN;
uint32_t broadcast_id;

NET_BUF_SIMPLE_DEFINE(ad_buf, BT_UUID_SIZE_16 + BT_AUDIO_BROADCAST_ID_SIZE);
NET_BUF_SIMPLE_DEFINE(base_buf, 128);

/* Broadcast Audio Streaming Endpoint advertising data */
struct bt_data base_ad[2];
struct bt_data per_ad;

err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
if (err) {
printk("Unable to generate broadcast ID: %d\n", err);

return -EINVAL;
}

*gap_settings = BIT(BTP_GAP_SETTINGS_DISCOVERABLE) |
BIT(BTP_GAP_SETTINGS_EXTENDED_ADVERTISING);
/* Setup extended advertising data */
net_buf_simple_add_le16(&ad_buf, BT_UUID_BROADCAST_AUDIO_VAL);
net_buf_simple_add_le24(&ad_buf, source->broadcast_id);
base_ad[0].type = BT_DATA_SVC_DATA16;
base_ad[0].data_len = ad_buf.len;
base_ad[0].data = ad_buf.data;
base_ad[1].type = BT_DATA_NAME_COMPLETE;
base_ad[1].data_len = sizeof(CONFIG_BT_DEVICE_NAME) - 1;
base_ad[1].data = CONFIG_BT_DEVICE_NAME;
err = tester_gap_create_adv_instance(&param, BTP_GAP_ADDR_TYPE_IDENTITY, base_ad, 2, NULL,
0, gap_settings);
if (err != 0) {
LOG_DBG("Failed to create extended advertising instance: %d", err);

return -EINVAL;
/* A more specialized adv instance may already have been created by another btp module */
if (tester_gap_ext_adv_get() == NULL) {
struct bt_le_adv_param param = *BT_LE_EXT_ADV_NCONN;
struct bt_data base_ad[2];

NET_BUF_SIMPLE_DEFINE(ad_buf, BT_UUID_SIZE_16 + BT_AUDIO_BROADCAST_ID_SIZE);
*gap_settings = BIT(BTP_GAP_SETTINGS_DISCOVERABLE) |
BIT(BTP_GAP_SETTINGS_EXTENDED_ADVERTISING);
/* Setup extended advertising data */
net_buf_simple_add_le16(&ad_buf, BT_UUID_BROADCAST_AUDIO_VAL);
net_buf_simple_add_le24(&ad_buf, source->broadcast_id);
base_ad[0].type = BT_DATA_SVC_DATA16;
base_ad[0].data_len = ad_buf.len;
base_ad[0].data = ad_buf.data;
base_ad[1].type = BT_DATA_NAME_COMPLETE;
base_ad[1].data_len = sizeof(CONFIG_BT_DEVICE_NAME) - 1;
base_ad[1].data = CONFIG_BT_DEVICE_NAME;

err = tester_gap_create_adv_instance(&param, BTP_GAP_ADDR_TYPE_IDENTITY, base_ad,
2, NULL, 0, gap_settings);
if (err != 0) {
LOG_DBG("Failed to create extended advertising instance: %d", err);

return -EINVAL;
}
}

err = tester_gap_padv_configure(BT_LE_PER_ADV_PARAM(BT_GAP_PER_ADV_FAST_INT_MIN_2,
Expand Down
Loading