From 7630161376771c035aafa32f2bc40abf6a669f99 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Wed, 14 Dec 2022 22:25:39 +0100 Subject: [PATCH] Bluetooth: Audio: Shell: Improve printing of incoming audio Instead of printing every audio packet (typically arriving every 7.5 or 10ms), we now only print every 100th. Ideally we would add support for changing the number of "skippe" audio packets at runtime in a shell command, but that will be postponed. Ideally we would also have a rx_cnt per stream, but that will also be postponed to the future, and should be fixed with e.g. the sequence number (seq_num) as well. Finally this commit also adds a verification if the currently incoming data packet contains the same ts or seq_num of the previous one, and print if it does, as this indicates that we are receiving some invalid data. Signed-off-by: Emil Gydesen --- subsys/bluetooth/shell/audio.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/shell/audio.c b/subsys/bluetooth/shell/audio.c index f9db128e609..70f6b42dd82 100644 --- a/subsys/bluetooth/shell/audio.c +++ b/subsys/bluetooth/shell/audio.c @@ -60,6 +60,7 @@ static struct bt_audio_broadcast_sink *default_sink; #endif /* CONFIG_BT_AUDIO_BROADCAST_SINK */ static struct bt_audio_stream *default_stream; static uint16_t seq_num; +static size_t rx_cnt; struct named_lc3_preset { const char *name; @@ -1410,7 +1411,29 @@ static void audio_recv(struct bt_audio_stream *stream, const struct bt_iso_recv_info *info, struct net_buf *buf) { - shell_print(ctx_shell, "Incoming audio on stream %p len %u\n", stream, buf->len); + static struct bt_iso_recv_info last_info; + + /* TODO: Make it possible to only print every X packets, and make X settable by the shell */ + if ((rx_cnt % 100) == 0) { + shell_print(ctx_shell, + "[%zu]: Incoming audio on stream %p len %u ts %u seq_num %u flags %u", + rx_cnt, stream, buf->len, info->ts, info->seq_num, + info->flags); + } + + if (info->ts == last_info.ts) { + shell_error(ctx_shell, "[%zu]: Duplicate TS: %u", + rx_cnt, info->ts); + } + + if (info->seq_num == last_info.seq_num) { + shell_error(ctx_shell, "[%zu]: Duplicate seq_num: %u", + rx_cnt, info->seq_num); + } + + (void)memcpy(&last_info, info, sizeof(last_info)); + + rx_cnt++; } #endif /* CONFIG_BT_AUDIO_UNICAST || CONFIG_BT_AUDIO_BROADCAST_SINK */