tests: Bluetooth: Add coverage for Coded PHY sync establishment

Adds test coverage for the case where the host starts the
scanner automatically upon sync creation.
This test covers there bug where we previously did not start
scanning on Coded PHY.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This commit is contained in:
Rubin Gerritsen 2024-04-29 15:26:53 +02:00 committed by Fabio Baltieri
commit 7fdc99a4cb
5 changed files with 106 additions and 1 deletions

View file

@ -20,6 +20,7 @@ app=tests/bsim/bluetooth/host/adv/extended conf_file=prj_advertiser.conf compile
app=tests/bsim/bluetooth/host/adv/extended conf_file=prj_scanner.conf compile
app=tests/bsim/bluetooth/host/adv/periodic compile
app=tests/bsim/bluetooth/host/adv/periodic conf_file=prj_long_data.conf compile
app=tests/bsim/bluetooth/host/adv/periodic conf_file=prj_coded.conf compile
app=tests/bsim/bluetooth/host/adv/encrypted/css_sample_data compile
app=tests/bsim/bluetooth/host/adv/encrypted/ead_sample compile
app=tests/bsim/bluetooth/host/adv/long_ad compile

View file

@ -0,0 +1,15 @@
CONFIG_BT=y
CONFIG_BT_DEVICE_NAME="test_per_adv"
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SMP=y
CONFIG_BT_PRIVACY=y
CONFIG_BT_EXT_ADV=y
CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_ADV_AUX_SET=2
CONFIG_BT_CTLR_ADV_DATA_BUF_MAX=2
CONFIG_BT_CTLR_PHY_CODED=y
CONFIG_BT_PER_ADV=y
CONFIG_BT_PER_ADV_SYNC=y

View file

@ -106,6 +106,30 @@ static void create_per_adv_set(struct bt_le_ext_adv **adv)
printk("done.\n");
}
#if defined(CONFIG_BT_CTLR_PHY_CODED)
static void create_per_adv_set_coded(struct bt_le_ext_adv **adv)
{
int err;
printk("Creating coded PHY extended advertising set...");
err = bt_le_ext_adv_create(BT_LE_EXT_ADV_CODED_NCONN, NULL, adv);
if (err) {
printk("Failed to create advertising set: %d\n", err);
return;
}
printk("done.\n");
printk("Setting periodic advertising parameters...");
err = bt_le_per_adv_set_param(*adv, BT_LE_PER_ADV_DEFAULT);
if (err) {
printk("Failed to set periodic advertising parameters: %d\n",
err);
return;
}
printk("done.\n");
}
#endif /* CONFIG_BT_CTLR_PHY_CODED */
static void create_conn_adv_set(struct bt_le_ext_adv **adv)
{
int err;
@ -228,6 +252,31 @@ static void main_per_adv_advertiser(void)
PASS("Periodic advertiser passed\n");
}
#if defined(CONFIG_BT_CTLR_PHY_CODED)
static void main_per_adv_advertiser_coded(void)
{
struct bt_le_ext_adv *per_adv;
common_init();
create_per_adv_set_coded(&per_adv);
start_per_adv_set(per_adv);
start_ext_adv_set(per_adv);
/* Advertise for a bit */
k_sleep(K_SECONDS(10));
stop_per_adv_set(per_adv);
stop_ext_adv_set(per_adv);
delete_adv_set(per_adv);
per_adv = NULL;
PASS("Periodic advertiser coded PHY passed\n");
}
#endif /* CONFIG_BT_CTLR_PHY_CODED */
static void main_per_adv_conn_advertiser(void)
{
struct bt_le_ext_adv *conn_adv;
@ -329,6 +378,16 @@ static const struct bst_test_instance per_adv_advertiser[] = {
.test_tick_f = test_tick,
.test_main_f = main_per_adv_advertiser
},
#if defined(CONFIG_BT_CTLR_PHY_CODED)
{
.test_id = "per_adv_advertiser_coded_phy",
.test_descr = "Basic periodic advertising test on Coded PHY. "
"Advertiser and periodic advertiser uses Coded PHY",
.test_post_init_f = test_init,
.test_tick_f = test_tick,
.test_main_f = main_per_adv_advertiser_coded
},
#endif /* CONFIG_BT_CTLR_PHY_CODED */
{
.test_id = "per_adv_conn_advertiser",
.test_descr = "Periodic advertising test with concurrent ACL "

View file

@ -190,7 +190,10 @@ static void start_scan(void)
int err;
printk("Start scanning...");
err = bt_le_scan_start(BT_LE_SCAN_ACTIVE, NULL);
err = bt_le_scan_start(IS_ENABLED(CONFIG_BT_CTLR_PHY_CODED) ?
BT_LE_SCAN_CODED_ACTIVE : BT_LE_SCAN_ACTIVE,
NULL);
if (err) {
FAIL("Failed to start scan: %d\n", err);
return;

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
# Periodic advertising sync test where the host starts scanning
# automatically because the application didn't start it.
# The advertiser is using Coded PHY as primary PHY.
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="per_adv_app_not_scanning_coded"
verbosity_level=2
cd ${BSIM_OUT_PATH}/bin
Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_periodic_prj_coded_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=per_adv_advertiser_coded_phy -rs=23
Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_periodic_prj_coded_conf \
-v=${verbosity_level} -s=${simulation_id} -d=1 -RealEncryption=0 \
-testid=per_adv_syncer_app_not_scanning -rs=6
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=20e6 $@
wait_for_background_jobs