From f1931bb8138a68e921ea5f7c826e8f64ff3b74f3 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Mon, 9 Jun 2025 02:58:02 +0200 Subject: [PATCH] samples: Bluetooth: bap_broadcast_sink: Fix logging invalid recv count Fix logging of invalid recv count by incrementing them before logging them. Signed-off-by: Vinayak Kariappa Chettimada --- .../bap_broadcast_sink/src/stream_rx.c | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/samples/bluetooth/bap_broadcast_sink/src/stream_rx.c b/samples/bluetooth/bap_broadcast_sink/src/stream_rx.c index 1caaec5361c..d441b820f5a 100644 --- a/samples/bluetooth/bap_broadcast_sink/src/stream_rx.c +++ b/samples/bluetooth/bap_broadcast_sink/src/stream_rx.c @@ -50,33 +50,41 @@ void stream_rx_recv(struct bt_bap_stream *bap_stream, const struct bt_iso_recv_i struct stream_rx *stream = CONTAINER_OF(bap_stream, struct stream_rx, stream); #if CONFIG_INFO_REPORTING_INTERVAL > 0 - if ((stream->reporting_info.recv_cnt % CONFIG_INFO_REPORTING_INTERVAL) == 0U) { - log_stream_rx(stream, info, buf); + bool do_log = false; + + stream->reporting_info.recv_cnt++; + if (stream->reporting_info.recv_cnt == 1U) { + /* Log first reception */ + do_log = true; + + } else if ((stream->reporting_info.recv_cnt % CONFIG_INFO_REPORTING_INTERVAL) == 0U) { + /* Log once for every CONFIG_INFO_REPORTING_INTERVAL reception */ + do_log = true; } - if (stream->reporting_info.recv_cnt > 0U && info->ts == stream->reporting_info.last_ts) { - log_stream_rx(stream, info, buf); - LOG_WRN("Duplicated timestamp received: %u\n", stream->reporting_info.last_ts); + if (stream->reporting_info.recv_cnt > 1U && info->ts == stream->reporting_info.last_ts) { stream->reporting_info.dup_ts_cnt++; + do_log = true; + LOG_WRN("Duplicated timestamp received: %u", stream->reporting_info.last_ts); } - if (stream->reporting_info.recv_cnt > 0U && + if (stream->reporting_info.recv_cnt > 1U && info->seq_num == stream->reporting_info.last_seq_num) { - log_stream_rx(stream, info, buf); - LOG_WRN("Duplicated PSN received: %u\n", stream->reporting_info.last_seq_num); stream->reporting_info.dup_psn_cnt++; + do_log = true; + LOG_WRN("Duplicated PSN received: %u", stream->reporting_info.last_seq_num); } if (info->flags & BT_ISO_FLAGS_ERROR) { - log_stream_rx(stream, info, buf); - LOG_DBG("ISO receive error\n"); stream->reporting_info.error_cnt++; + do_log = true; + LOG_DBG("ISO receive error"); } if (info->flags & BT_ISO_FLAGS_LOST) { - log_stream_rx(stream, info, buf); - LOG_DBG("ISO receive lost\n"); stream->reporting_info.loss_cnt++; + do_log = true; + LOG_DBG("ISO receive lost"); } if (info->flags & BT_ISO_FLAGS_VALID) { @@ -87,9 +95,12 @@ void stream_rx_recv(struct bt_bap_stream *bap_stream, const struct bt_iso_recv_i } } + if (do_log) { + log_stream_rx(stream, info, buf); + } + stream->reporting_info.last_seq_num = info->seq_num; stream->reporting_info.last_ts = info->ts; - stream->reporting_info.recv_cnt++; #endif /* CONFIG_INFO_REPORTING_INTERVAL > 0 */ total_rx_iso_packet_count++;