Skip to content

Commit 303bcfd

Browse files
Thalleycarlescufi
authored andcommitted
Bluetooth: Shell: Add testcases for AUDIO_RX and TX disabled
Add configurations where CONFIG_BT_AUDIO_TX and CONFIG_BT_AUDIO_RX are disabled. Fixes issues found in the BT shell implemented caused by these configurations. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
1 parent 2c5a249 commit 303bcfd

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

subsys/bluetooth/audio/shell/bap.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ static struct bt_codec_qos broadcast_source_qos;
6161
static struct bt_bap_stream broadcast_sink_streams[BROADCAST_SNK_STREAM_CNT];
6262
static struct bt_bap_broadcast_sink *default_sink;
6363
#endif /* CONFIG_BT_BAP_BROADCAST_SINK */
64-
static struct bt_bap_stream *txing_stream;
6564
static struct bt_bap_stream *default_stream;
66-
static uint16_t seq_num;
67-
static size_t rx_cnt;
6865

6966
static const struct named_lc3_preset lc3_unicast_presets[] = {
7067
{"8_1_1", BT_BAP_LC3_UNICAST_PRESET_8_1_1(LOCATION, CONTEXT)},
@@ -144,6 +141,10 @@ const struct named_lc3_preset *default_source_preset = &lc3_unicast_presets[3];
144141
static const struct named_lc3_preset *default_broadcast_source_preset = &lc3_broadcast_presets[3];
145142
static bool initialized;
146143

144+
#if defined(CONFIG_BT_AUDIO_TX)
145+
static struct bt_bap_stream *txing_stream;
146+
static uint16_t seq_num;
147+
147148
static uint16_t get_next_seq_num(uint32_t interval_us)
148149
{
149150
static int64_t last_ticks;
@@ -165,8 +166,9 @@ static uint16_t get_next_seq_num(uint32_t interval_us)
165166

166167
return (uint16_t)next_seq_num;
167168
}
169+
#endif /* CONFIG_BT_AUDIO_TX */
168170

169-
#if defined(CONFIG_LIBLC3)
171+
#if defined(CONFIG_LIBLC3) && defined(CONFIG_BT_AUDIO_TX)
170172
NET_BUF_POOL_FIXED_DEFINE(sine_tx_pool, CONFIG_BT_ISO_TX_BUF_COUNT,
171173
CONFIG_BT_ISO_TX_MTU + BT_ISO_CHAN_SEND_RESERVE,
172174
8, NULL);
@@ -363,7 +365,7 @@ static void lc3_audio_timer_timeout(struct k_work *work)
363365
}
364366

365367
static K_WORK_DELAYABLE_DEFINE(audio_send_work, lc3_audio_timer_timeout);
366-
#endif /* CONFIG_LIBLC3 */
368+
#endif /* CONFIG_LIBLC3 && CONFIG_BT_AUDIO_TX */
367369

368370
static void print_codec(const struct bt_codec *codec)
369371
{
@@ -534,7 +536,9 @@ static int lc3_start(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp)
534536
{
535537
shell_print(ctx_shell, "Start: stream %p", stream);
536538

539+
#if defined(CONFIG_BT_AUDIO_TX)
537540
seq_num = 0;
541+
#endif /* CONFIG_BT_AUDIO_TX */
538542

539543
return 0;
540544
}
@@ -1725,6 +1729,7 @@ static void audio_recv(struct bt_bap_stream *stream,
17251729
struct net_buf *buf)
17261730
{
17271731
static struct bt_iso_recv_info last_info;
1732+
static size_t rx_cnt;
17281733

17291734
/* TODO: Make it possible to only print every X packets, and make X settable by the shell */
17301735
if ((rx_cnt % 100) == 0) {
@@ -2380,6 +2385,7 @@ static int cmd_init(const struct shell *sh, size_t argc, char *argv[])
23802385
return 0;
23812386
}
23822387

2388+
#if defined(CONFIG_BT_AUDIO_TX)
23832389
#define DATA_MTU CONFIG_BT_ISO_TX_MTU
23842390
NET_BUF_POOL_FIXED_DEFINE(tx_pool, 1, DATA_MTU, 8, NULL);
23852391

@@ -2486,6 +2492,7 @@ static int cmd_stop_sine(const struct shell *sh, size_t argc, char *argv[])
24862492
return 0;
24872493
}
24882494
#endif /* CONFIG_LIBLC3 */
2495+
#endif /* CONFIG_BT_AUDIO_TX */
24892496

24902497
#if defined(CONFIG_BT_BAP_UNICAST_SERVER)
24912498
static void print_ase_info(struct bt_bap_ep *ep, void *user_data)
@@ -2550,16 +2557,17 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
25502557
SHELL_CMD_ARG(start, NULL, NULL, cmd_start, 1, 0),
25512558
SHELL_CMD_ARG(disable, NULL, NULL, cmd_disable, 1, 0),
25522559
SHELL_CMD_ARG(release, NULL, NULL, cmd_release, 1, 0),
2553-
SHELL_CMD_ARG(select_unicast, NULL, "<stream>",
2554-
cmd_select_unicast, 2, 0),
2560+
SHELL_CMD_ARG(select_unicast, NULL, "<stream>", cmd_select_unicast, 2, 0),
25552561
#endif /* CONFIG_BT_BAP_UNICAST */
25562562
SHELL_CMD_ARG(preset, NULL, "<sink, source, broadcast> [preset]", cmd_preset, 2, 1),
2563+
#if defined(CONFIG_BT_AUDIO_TX)
25572564
SHELL_CMD_ARG(send, NULL, "Send to Audio Stream [data]", cmd_send, 1, 1),
25582565
#if defined(CONFIG_LIBLC3)
25592566
SHELL_CMD_ARG(start_sine, NULL, "Start sending a LC3 encoded sine wave", cmd_start_sine, 1,
25602567
0),
25612568
SHELL_CMD_ARG(stop_sine, NULL, "Stop sending a LC3 encoded sine wave", cmd_stop_sine, 1, 0),
25622569
#endif /* CONFIG_LIBLC3 */
2570+
#endif /* CONFIG_BT_AUDIO_TX */
25632571
SHELL_COND_CMD_ARG(CONFIG_BT_PACS, set_location, NULL,
25642572
"<direction: sink, source> <location bitmask>", cmd_set_loc, 3, 0),
25652573
SHELL_COND_CMD_ARG(CONFIG_BT_PACS, set_context, NULL,

tests/bluetooth/shell/testcase.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,22 @@ tests:
237237
platform_allow: native_posix
238238
extra_configs:
239239
- CONFIG_BT_BAP_BROADCAST_SINK=n
240+
bluetooth.audio_shell.no_audio_tx:
241+
extra_args: CONF_FILE="audio.conf"
242+
build_only: true
243+
platform_allow: native_posix
244+
extra_configs:
245+
- CONFIG_BT_BAP_BROADCAST_SOURCE=n
246+
- CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT=0
247+
- CONFIG_BT_ASCS_ASE_SRC_COUNT=0
248+
bluetooth.audio_shell.no_audio_rx:
249+
extra_args: CONF_FILE="audio.conf"
250+
build_only: true
251+
platform_allow: native_posix
252+
extra_configs:
253+
- CONFIG_BT_BAP_BROADCAST_SINK=n
254+
- CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT=0
255+
- CONFIG_BT_ASCS_ASE_SNK_COUNT=0
240256
bluetooth.audio_shell.no_has:
241257
extra_args: CONF_FILE="audio.conf"
242258
build_only: true

0 commit comments

Comments
 (0)