1#!/bin/env bash
2# Copyright 2023 Nordic Semiconductor ASA
3# SPDX-License-Identifier: Apache-2.0
4
5set -eu
6
7source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
8
9verbosity_level=2
10simulation_id="$(guess_test_long_name)"
11test_exe="${BSIM_OUT_PATH}/bin/bs_${BOARD_TS}_$(guess_test_long_name)_prj_conf"
12
13cd ${BSIM_OUT_PATH}/bin
14
15TEST_ARGS=(
16    "leg_conn_scan_active"
17    "leg_conn_nscan_passive"
18    "ext_nconn_scan_active"
19    "ext_conn_nscan_passive"
20)
21TEST_ADDR_TYPE=("identity" "rpa")
22
23sim_id_count=0
24for args in ${TEST_ARGS[@]}; do
25    args=($(echo "${args}" | sed 's/_/ /g'))
26
27    use_ext_adv=0
28    if [ "${args[0]}" == "ext" ]; then
29        use_ext_adv=1
30    fi
31
32    connectable=0
33    if [ "${args[1]}" == "conn" ]; then
34        connectable=1
35    fi
36
37    scannable=0
38    if [ "${args[2]}" == "scan" ]; then
39        scannable=1
40    fi
41
42    use_active_scan=0
43    if [ "${args[3]}" == "active" ]; then
44        use_active_scan=1
45    fi
46
47    for addr_type in "${TEST_ADDR_TYPE[@]}"; do
48        echo "Starting iteration $sim_id_count: ${args[@]} $addr_type"
49        echo "################################################"
50
51        Execute "$test_exe" \
52            -v=${verbosity_level} -s="${simulation_id}_${sim_id_count}" -d=0 -testid=central \
53            -RealEncryption=1 -argstest sim-id=${sim_id_count} connection-test=${connectable} \
54            active-scan=${use_active_scan} addr-type="${addr_type}"
55
56        Execute "$test_exe" \
57            -v=${verbosity_level} -s="${simulation_id}_${sim_id_count}" -d=1 -testid=peripheral \
58            -RealEncryption=1 -argstest sim-id=${sim_id_count} addr-type="${addr_type}" \
59            use-ext-adv=${use_ext_adv} scannable=${scannable} connectable=${connectable}
60
61        Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s="${simulation_id}_${sim_id_count}" \
62            -D=2 -sim_length=60e6 $@
63
64        wait_for_background_jobs
65
66        sim_id_count=$(( sim_id_count + 1 ))
67    done
68done
69
70