|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Copyright (c) 2025 Nordic Semiconductor ASA |
| 4 | +# |
| 5 | +# SPDX-License-Identifier: Apache-2.0 |
| 6 | + |
| 7 | +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source |
| 8 | + |
| 9 | +VERBOSITY_LEVEL=2 |
| 10 | +EXECUTE_TIMEOUT=60 |
| 11 | +BSIM_EXE=./bs_${BOARD_TS}_tests_bsim_bluetooth_audio_prj_conf |
| 12 | + |
| 13 | +cd ${BSIM_OUT_PATH}/bin |
| 14 | + |
| 15 | +function Execute_ac() { |
| 16 | + local profile="" |
| 17 | + local audio_config="" |
| 18 | + local sink_preset="" |
| 19 | + local source_preset="" |
| 20 | + local acceptor_count="" |
| 21 | + local initiator_test_id="" |
| 22 | + local acceptor_test_id="" |
| 23 | + |
| 24 | + OPTIND=1 # Reset OPTIND at the start of the function |
| 25 | + |
| 26 | + while getopts "p:c:t:r:n:i:a:q:h" option; do |
| 27 | + case "${option}" in |
| 28 | + p) |
| 29 | + profile=${OPTARG} |
| 30 | + ;; |
| 31 | + c) |
| 32 | + audio_config=${OPTARG} |
| 33 | + ;; |
| 34 | + t) |
| 35 | + sink_preset=${OPTARG} # TX preset |
| 36 | + ;; |
| 37 | + r) |
| 38 | + source_preset=${OPTARG} # RX preset |
| 39 | + ;; |
| 40 | + n) |
| 41 | + acceptor_count=${OPTARG} |
| 42 | + ;; |
| 43 | + i) |
| 44 | + initiator_test_id=${OPTARG} |
| 45 | + ;; |
| 46 | + a) |
| 47 | + acceptor_test_id=${OPTARG} |
| 48 | + ;; |
| 49 | + q) |
| 50 | + sink_preset_arg_name=${OPTARG} |
| 51 | + ;; |
| 52 | + h) |
| 53 | + echo "Usage: $0 [-p profile] [-c audio_configuration] [-t sink_preset] " \ |
| 54 | + "[-r source_preset] [-n acceptor_count] [-i initiator_test_id] " \ |
| 55 | + "[-a acceptor_test_id] [-q sink_preset_arg_name] [-h]" |
| 56 | + return 0 |
| 57 | + ;; |
| 58 | + *) |
| 59 | + echo "Invalid option. Use -h for help." |
| 60 | + return 1 |
| 61 | + ;; |
| 62 | + esac |
| 63 | + done |
| 64 | + |
| 65 | + if [[ -n $sink_preset ]]; then |
| 66 | + sink_preset_arg="${sink_preset_arg_name} ${sink_preset}" |
| 67 | + else |
| 68 | + sink_preset_arg="" |
| 69 | + fi |
| 70 | + |
| 71 | + if [[ -n $source_preset ]]; then |
| 72 | + source_preset_arg="source_preset ${source_preset}" |
| 73 | + else |
| 74 | + source_preset_arg="" |
| 75 | + fi |
| 76 | + |
| 77 | + |
| 78 | + sim_id="cap_unicast_ac_${audio_config}_${sink_preset}_${source_preset}" |
| 79 | + |
| 80 | + printf "\n\n======== Running %s AC_%s with %s %s =========\n\n" \ |
| 81 | + "${profile}" "${audio_config}" "${sink_preset_arg}" "${source_preset_arg}" |
| 82 | + |
| 83 | + let device_count=1+${acceptor_count} |
| 84 | + initiator_test_id=${initiator_test_id}_${audio_config} |
| 85 | + |
| 86 | + Execute ${BSIM_EXE} -v=${VERBOSITY_LEVEL} -s=${sim_id} -d=0 -testid=${initiator_test_id} \ |
| 87 | + -RealEncryption=1 -rs=23 -D=${device_count} \ |
| 88 | + -argstest ${sink_preset_arg} ${source_preset_arg} |
| 89 | + |
| 90 | + for i in $(seq 1 $acceptor_count); do |
| 91 | + let rs=${i}*7 # ensure unique RS value per acceptor |
| 92 | + |
| 93 | + Execute ${BSIM_EXE} -v=${VERBOSITY_LEVEL} -s=${sim_id} -d=${i} -testid=${acceptor_test_id} \ |
| 94 | + -RealEncryption=1 -rs=${rs} -D=${device_count} |
| 95 | + done |
| 96 | + |
| 97 | + Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${sim_id} -D=${device_count} -sim_length=60e6 |
| 98 | + |
| 99 | + wait_for_background_jobs |
| 100 | +} |
| 101 | + |
| 102 | +function Execute_cap_unicast_ac() { |
| 103 | + Execute_ac -p "CAP" -i cap_initiator_ac -a cap_acceptor_unicast -q sink_preset "$@" |
| 104 | +} |
| 105 | + |
| 106 | +function Execute_cap_broadcast_ac() { |
| 107 | + Execute_ac -p "CAP" -i cap_initiator_ac -a cap_acceptor_broadcast -q preset "$@" |
| 108 | +} |
| 109 | + |
| 110 | +function Execute_gmap_unicast_ac() { |
| 111 | + Execute_ac -p "GMAP" -i gmap_ugg_ac -a gmap_ugt -q sink_preset "$@" |
| 112 | +} |
| 113 | + |
| 114 | +function Execute_gmap_broadcast_ac() { |
| 115 | + Execute_ac -p "GMAP" -i gmap_ugg_ac -a gmap_ugt -q broadcast_preset "$@" |
| 116 | +} |
0 commit comments