Skip to content
Draft
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
5 changes: 5 additions & 0 deletions tests/bluetooth/tester/boards/nrf5340bsim_nrf5340_cpuapp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ CONFIG_UART_PIPE=n
CONFIG_UART_INTERRUPT_DRIVEN=y

CONFIG_SERIAL=y

# Increase the number of RX buffers to a high amount to avoid issues with running out of buffers
# Presumably this is due to the speed of BSIM and the "slowness" of the BSIM UART, since all
# events (include ISO data received event) is sent in a blocking manner
CONFIG_BT_ISO_RX_BUF_COUNT=30
4 changes: 3 additions & 1 deletion tests/bluetooth/tester/overlay-bt_ll_sw_split.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ CONFIG_BT_CTLR_ISO_TX_SDU_LEN_MAX=310

# CSIP tests requires up to 3 devices
CONFIG_BT_MAX_CONN=3
CONFIG_MBEDTLS_PSA_KEY_SLOT_COUNT=3
# TODO: For some reason setting CONFIG_MBEDTLS_PSA_KEY_SLOT_COUNT=3 cause pairing issues on
# the nr52_bsim
CONFIG_MBEDTLS_PSA_KEY_SLOT_COUNT=4

# BAP/BSRC/SCC/BV-38-C requires 2 BIGs
CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
Expand Down
8 changes: 8 additions & 0 deletions tests/bluetooth/tester/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ tests:
build_only: true
platform_allow:
- nrf52_bsim/native
extra_args:
- EXTRA_CONF_FILE="overlay-le-audio.conf;overlay-bt_ll_sw_split.conf"
harness: bsim
harness_config:
bsim_exe_name: tests_bluetooth_tester_le_audio_prj_conf
bluetooth.general.tester_hci_ipc_le_audio_bsim:
build_only: true
platform_allow:
- nrf5340bsim/nrf5340/cpuapp
extra_args:
- EXTRA_CONF_FILE="overlay-le-audio.conf"
Expand Down
8 changes: 8 additions & 0 deletions tests/bsim/bluetooth/tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ zephyr_include_directories(
target_sources(app PRIVATE
src/bsim_btp.c
src/test_main.c
src/audio/bap_broadcast_sink.c
src/audio/bap_broadcast_source.c
src/audio/bap_central.c
src/audio/bap_peripheral.c
src/audio/cap_broadcast_sink.c
src/audio/cap_broadcast_source.c
src/audio/cap_central.c
src/audio/cap_peripheral.c
src/audio/ccp_central.c
src/audio/ccp_peripheral.c
src/audio/csip_central.c
Expand Down
78 changes: 78 additions & 0 deletions tests/bsim/bluetooth/tester/src/audio/bap_broadcast_sink.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/util_macro.h>

#include "babblekit/testcase.h"
#include "bstests.h"

#include "btp/btp.h"
#include "bsim_btp.h"

LOG_MODULE_REGISTER(bsim_bap_broadcast_sink, CONFIG_BSIM_BTTESTER_LOG_LEVEL);

static void test_bap_broadcast_sink(void)
{
const uint16_t pa_sync_timeout = BT_GAP_PER_ADV_MAX_TIMEOUT;
char addr_str[BT_ADDR_LE_STR_LEN];
const uint16_t pa_sync_skip = 0U;
const uint8_t src_id = 0U; /* BASS receive state source ID */
bt_addr_le_t remote_addr;
uint32_t broadcast_id;
uint8_t adv_sid;
uint8_t bis_id;

bsim_btp_uart_init();

bsim_btp_wait_for_evt(BTP_SERVICE_ID_CORE, BTP_CORE_EV_IUT_READY, NULL);

bsim_btp_core_register(BTP_SERVICE_ID_GAP);
bsim_btp_core_register(BTP_SERVICE_ID_BAP);
bsim_btp_core_register(BTP_SERVICE_ID_PACS);

bsim_btp_bap_broadcast_sink_setup();
bsim_btp_bap_broadcast_scan_start();

bsim_btp_bap_broadcast_scan_start();
bsim_btp_wait_for_bap_baa_found(&remote_addr, &broadcast_id, &adv_sid);
bt_addr_le_to_str(&remote_addr, addr_str, sizeof(addr_str));
LOG_INF("Found remote device %s", addr_str);
bsim_btp_bap_broadcast_scan_stop();

bsim_btp_bap_broadcast_sink_sync(&remote_addr, broadcast_id, adv_sid, pa_sync_skip,
pa_sync_timeout, false, src_id);
bsim_btp_wait_for_bap_bap_bis_found(&bis_id);
bsim_btp_bap_broadcast_sink_bis_sync(&remote_addr, broadcast_id,
BT_ISO_BIS_INDEX_BIT(bis_id));
bsim_btp_wait_for_btp_bap_bis_synced();
bsim_btp_wait_for_bap_bis_stream_received();
bsim_btp_bap_broadcast_sink_stop(&remote_addr, broadcast_id);
bsim_btp_bap_broadcast_sink_release();

TEST_PASS("PASSED\n");
}

static const struct bst_test_instance test_sample[] = {
{
.test_id = "bap_broadcast_sink",
.test_descr = "Smoketest for the BAP Broadcast Sink BT Tester behavior",
.test_main_f = test_bap_broadcast_sink,
},
BSTEST_END_MARKER,
};

struct bst_test_list *test_bap_broadcast_sink_install(struct bst_test_list *tests)
{
return bst_add_tests(tests, test_sample);
}
75 changes: 75 additions & 0 deletions tests/bsim/bluetooth/tester/src/audio/bap_broadcast_source.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stddef.h>
#include <stdint.h>

#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/lc3.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/net_buf.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>

#include "babblekit/testcase.h"
#include "bstests.h"

#include "btp/btp.h"
#include "bsim_btp.h"

LOG_MODULE_REGISTER(bsim_bap_broadcast_source, CONFIG_BSIM_BTTESTER_LOG_LEVEL);

static void test_bap_broadcast_source(void)
{
const uint8_t cc_data_16_2_1[] = BT_AUDIO_CODEC_CFG_LC3_DATA(
BT_AUDIO_CODEC_CFG_FREQ_16KHZ, BT_AUDIO_CODEC_CFG_DURATION_10,
BT_AUDIO_LOCATION_FRONT_LEFT, 40, 1);
const uint8_t coding_format = BT_HCI_CODING_FORMAT_LC3;
const uint8_t framing = BT_ISO_FRAMING_UNFRAMED;
const uint32_t presentation_delay = 40000U;
const uint32_t broadcast_id = 0x123456;
const uint8_t streams_per_subgroup = 1U;
const uint32_t sdu_interval = 10000U;
const uint16_t max_latency = 10U;
const uint16_t max_sdu = 40U;
const uint8_t subgroups = 1U;
const uint16_t cid = 0U; /* shall be 0 for LC3 */
const uint16_t vid = 0U; /* shall be 0 for LC3 */
const uint8_t rtn = 2U;

bsim_btp_uart_init();

bsim_btp_wait_for_evt(BTP_SERVICE_ID_CORE, BTP_CORE_EV_IUT_READY, NULL);

bsim_btp_core_register(BTP_SERVICE_ID_GAP);
bsim_btp_core_register(BTP_SERVICE_ID_BAP);

bsim_btp_bap_broadcast_source_setup_v2(broadcast_id, streams_per_subgroup, subgroups,
sdu_interval, framing, max_sdu, rtn, max_latency,
presentation_delay, coding_format, vid, cid,
ARRAY_SIZE(cc_data_16_2_1), cc_data_16_2_1);
bsim_btp_bap_broadcast_adv_start(broadcast_id);
bsim_btp_bap_broadcast_source_start(broadcast_id);

TEST_PASS("PASSED\n");
}

static const struct bst_test_instance test_sample[] = {
{
.test_id = "bap_broadcast_source",
.test_descr = "Smoketest for the BAP broadcast source BT Tester behavior",
.test_main_f = test_bap_broadcast_source,
},
BSTEST_END_MARKER,
};

struct bst_test_list *test_bap_broadcast_source_install(struct bst_test_list *tests)
{
return bst_add_tests(tests, test_sample);
}
113 changes: 113 additions & 0 deletions tests/bsim/bluetooth/tester/src/audio/bap_central.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stddef.h>
#include <stdint.h>

#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/lc3.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/net_buf.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>

#include "babblekit/testcase.h"
#include "bstests.h"

#include "btp/btp.h"
#include "bsim_btp.h"

LOG_MODULE_REGISTER(bsim_bap_central, CONFIG_BSIM_BTTESTER_LOG_LEVEL);

static void test_bap_central(void)
{
uint8_t cc_data_16_2_1[] = BT_AUDIO_CODEC_CFG_LC3_DATA(BT_AUDIO_CODEC_CFG_FREQ_16KHZ,
BT_AUDIO_CODEC_CFG_DURATION_10,
BT_AUDIO_LOCATION_FRONT_LEFT, 40, 1);

char addr_str[BT_ADDR_LE_STR_LEN];
const uint8_t cig_id = 0U;
const uint8_t cis_id = 0U;
const uint32_t sdu_interval = 10000U;
const uint8_t framing = BT_ISO_FRAMING_UNFRAMED;
const uint16_t max_sdu = 40U;
const uint8_t rtn = 2U;
const uint16_t max_latency = 10U;
const uint32_t presentation_delay = 40000U;
bt_addr_le_t remote_addr;
uint8_t ase_id;

bsim_btp_uart_init();

bsim_btp_wait_for_evt(BTP_SERVICE_ID_CORE, BTP_CORE_EV_IUT_READY, NULL);

bsim_btp_core_register(BTP_SERVICE_ID_GAP);
bsim_btp_core_register(BTP_SERVICE_ID_BAP);
bsim_btp_core_register(BTP_SERVICE_ID_ASCS);
bsim_btp_core_register(BTP_SERVICE_ID_PACS);

bsim_btp_gap_start_discovery(BTP_GAP_DISCOVERY_FLAG_LE);
bsim_btp_wait_for_gap_device_found(&remote_addr);
bt_addr_le_to_str(&remote_addr, addr_str, sizeof(addr_str));
LOG_INF("Found remote device %s", addr_str);

bsim_btp_gap_stop_discovery();
bsim_btp_gap_connect(&remote_addr, BTP_GAP_ADDR_TYPE_IDENTITY);
bsim_btp_wait_for_gap_device_connected(NULL);
LOG_INF("Device %s connected", addr_str);

bsim_btp_gap_pair(&remote_addr);
bsim_btp_wait_for_gap_sec_level_changed(NULL, NULL);

bsim_btp_bap_discover(&remote_addr);
bsim_btp_wait_for_bap_ase_found(&ase_id);
bsim_btp_wait_for_bap_discovered();

bsim_btp_ascs_configure_codec(&remote_addr, ase_id, BT_HCI_CODING_FORMAT_LC3, 0U, 0U,
ARRAY_SIZE(cc_data_16_2_1), cc_data_16_2_1);
bsim_btp_wait_for_ascs_operation_complete();

/* The CIS must be preconfigured before sending the request to the BAP unicast server */
bsim_btp_ascs_add_ase_to_cis(&remote_addr, ase_id, cig_id, cis_id);
btp_ascs_preconfigure_qos(cig_id, cis_id, sdu_interval, framing, max_sdu, rtn, max_latency,
presentation_delay);

bsim_btp_ascs_configure_qos(&remote_addr, ase_id, cig_id, cis_id, sdu_interval, framing,
max_sdu, rtn, max_latency, presentation_delay);
bsim_btp_wait_for_ascs_operation_complete();

bsim_btp_ascs_enable(&remote_addr, ase_id);
bsim_btp_wait_for_ascs_operation_complete();

bsim_btp_ascs_receiver_start_ready(&remote_addr, ase_id);
bsim_btp_wait_for_ascs_operation_complete();

bsim_btp_ascs_release(&remote_addr, ase_id);
bsim_btp_wait_for_ascs_operation_complete();

bsim_btp_gap_disconnect(&remote_addr);
bsim_btp_wait_for_gap_device_disconnected(NULL);
LOG_INF("Device %s disconnected", addr_str);

TEST_PASS("PASSED\n");
}

static const struct bst_test_instance test_sample[] = {
{
.test_id = "bap_central",
.test_descr = "Smoketest for the BAP central BT Tester behavior",
.test_main_f = test_bap_central,
},
BSTEST_END_MARKER,
};

struct bst_test_list *test_bap_central_install(struct bst_test_list *tests)
{
return bst_add_tests(tests, test_sample);
}
60 changes: 60 additions & 0 deletions tests/bsim/bluetooth/tester/src/audio/bap_peripheral.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stddef.h>
#include <stdint.h>

#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/util_macro.h>

#include "babblekit/testcase.h"
#include "bstests.h"

#include "btp/btp.h"
#include "bsim_btp.h"

LOG_MODULE_REGISTER(bsim_bap_peripheral, CONFIG_BSIM_BTTESTER_LOG_LEVEL);

static void test_bap_peripheral(void)
{
char addr_str[BT_ADDR_LE_STR_LEN];
bt_addr_le_t remote_addr;

bsim_btp_uart_init();

bsim_btp_wait_for_evt(BTP_SERVICE_ID_CORE, BTP_CORE_EV_IUT_READY, NULL);

bsim_btp_core_register(BTP_SERVICE_ID_GAP);
bsim_btp_core_register(BTP_SERVICE_ID_BAP);
bsim_btp_core_register(BTP_SERVICE_ID_ASCS);
bsim_btp_core_register(BTP_SERVICE_ID_PACS);

bsim_btp_gap_set_discoverable(BTP_GAP_GENERAL_DISCOVERABLE);
bsim_btp_gap_start_advertising(0U, 0U, NULL, BT_HCI_OWN_ADDR_PUBLIC);
bsim_btp_wait_for_gap_device_connected(&remote_addr);
bt_addr_le_to_str(&remote_addr, addr_str, sizeof(addr_str));
LOG_INF("Device %s connected", addr_str);
bsim_btp_wait_for_gap_device_disconnected(NULL);
LOG_INF("Device %s disconnected", addr_str);

TEST_PASS("PASSED\n");
}

static const struct bst_test_instance test_sample[] = {
{
.test_id = "bap_peripheral",
.test_descr = "Smoketest for the BAP peripheral BT Tester behavior",
.test_main_f = test_bap_peripheral,
},
BSTEST_END_MARKER,
};

struct bst_test_list *test_bap_peripheral_install(struct bst_test_list *tests)
{
return bst_add_tests(tests, test_sample);
}
Loading
Loading