Commit d229b89a authored by Emil Gydesen's avatar Emil Gydesen Committed by Anas Nashif
Browse files

Bluetooth: BAP: Shell: Add tracking of empty SDUs



There are devices that will send empty SDUs instead of
empty PDUs, and while that should be harmless, it is nice
to know what is going on, and we may want to deal with
empty SDUs and empty PDUs differently.

This also modifies the state for TS and PSN to only be
applied for valid ISO packets.

Signed-off-by: default avatarEmil Gydesen <emil.gydesen@nordicsemi.no>
parent 1d5acb75
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ struct shell_stream {
#endif /* CONFIG_BT_AUDIO_TX */
#if defined(CONFIG_BT_AUDIO_RX)
	struct bt_iso_recv_info last_info;
	size_t empty_sdu_pkts;
	size_t lost_pkts;
	size_t err_pkts;
	size_t dup_psn;
+21 −11
Original line number Diff line number Diff line
@@ -2338,6 +2338,9 @@ static void audio_recv(struct bt_bap_stream *stream,

	sh_stream->rx_cnt++;

	if ((info->flags & BT_ISO_FLAGS_VALID) != 0) {
		/* For valid ISO packets we check if they are invalid in other ways */

		if (info->ts == sh_stream->last_info.ts) {
			sh_stream->dup_ts++;
		}
@@ -2346,6 +2349,11 @@ static void audio_recv(struct bt_bap_stream *stream,
			sh_stream->dup_psn++;
		}

		if (buf->len == 0U) {
			sh_stream->empty_sdu_pkts++;
		}
	}

	if (info->flags & BT_ISO_FLAGS_ERROR) {
		sh_stream->err_pkts++;
	}
@@ -2355,12 +2363,13 @@ static void audio_recv(struct bt_bap_stream *stream,
	}

	if ((sh_stream->rx_cnt % recv_stats_interval) == 0) {
		shell_print(ctx_shell,
		shell_print(
			ctx_shell,
			"[%zu]: Incoming audio on stream %p len %u ts %u seq_num %u flags %u "
			    "(dup ts %zu; dup psn %zu, err_pkts %zu, lost_pkts %zu)",
			    sh_stream->rx_cnt, stream, buf->len, info->ts, info->seq_num,
			    info->flags, sh_stream->dup_ts, sh_stream->dup_psn, sh_stream->err_pkts,
			    sh_stream->lost_pkts);
			"(dup ts %zu; dup psn %zu, err_pkts %zu, lost_pkts %zu, empty SDUs %zu)",
			sh_stream->rx_cnt, stream, buf->len, info->ts, info->seq_num, info->flags,
			sh_stream->dup_ts, sh_stream->dup_psn, sh_stream->err_pkts,
			sh_stream->lost_pkts, sh_stream->empty_sdu_pkts);
	}

	(void)memcpy(&sh_stream->last_info, info, sizeof(sh_stream->last_info));
@@ -2421,6 +2430,7 @@ static void stream_started_cb(struct bt_bap_stream *bap_stream)
	printk("Stream %p started\n", bap_stream);

#if defined(CONFIG_BT_AUDIO_RX)
	sh_stream->empty_sdu_pkts = 0U;
	sh_stream->lost_pkts = 0U;
	sh_stream->err_pkts = 0U;
	sh_stream->dup_psn = 0U;