Skip to content

Commit f1931bb

Browse files
cvinayakdanieldegrasse
authored andcommitted
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 <[email protected]>
1 parent 01c9c67 commit f1931bb

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

samples/bluetooth/bap_broadcast_sink/src/stream_rx.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,41 @@ void stream_rx_recv(struct bt_bap_stream *bap_stream, const struct bt_iso_recv_i
5050
struct stream_rx *stream = CONTAINER_OF(bap_stream, struct stream_rx, stream);
5151

5252
#if CONFIG_INFO_REPORTING_INTERVAL > 0
53-
if ((stream->reporting_info.recv_cnt % CONFIG_INFO_REPORTING_INTERVAL) == 0U) {
54-
log_stream_rx(stream, info, buf);
53+
bool do_log = false;
54+
55+
stream->reporting_info.recv_cnt++;
56+
if (stream->reporting_info.recv_cnt == 1U) {
57+
/* Log first reception */
58+
do_log = true;
59+
60+
} else if ((stream->reporting_info.recv_cnt % CONFIG_INFO_REPORTING_INTERVAL) == 0U) {
61+
/* Log once for every CONFIG_INFO_REPORTING_INTERVAL reception */
62+
do_log = true;
5563
}
5664

57-
if (stream->reporting_info.recv_cnt > 0U && info->ts == stream->reporting_info.last_ts) {
58-
log_stream_rx(stream, info, buf);
59-
LOG_WRN("Duplicated timestamp received: %u\n", stream->reporting_info.last_ts);
65+
if (stream->reporting_info.recv_cnt > 1U && info->ts == stream->reporting_info.last_ts) {
6066
stream->reporting_info.dup_ts_cnt++;
67+
do_log = true;
68+
LOG_WRN("Duplicated timestamp received: %u", stream->reporting_info.last_ts);
6169
}
6270

63-
if (stream->reporting_info.recv_cnt > 0U &&
71+
if (stream->reporting_info.recv_cnt > 1U &&
6472
info->seq_num == stream->reporting_info.last_seq_num) {
65-
log_stream_rx(stream, info, buf);
66-
LOG_WRN("Duplicated PSN received: %u\n", stream->reporting_info.last_seq_num);
6773
stream->reporting_info.dup_psn_cnt++;
74+
do_log = true;
75+
LOG_WRN("Duplicated PSN received: %u", stream->reporting_info.last_seq_num);
6876
}
6977

7078
if (info->flags & BT_ISO_FLAGS_ERROR) {
71-
log_stream_rx(stream, info, buf);
72-
LOG_DBG("ISO receive error\n");
7379
stream->reporting_info.error_cnt++;
80+
do_log = true;
81+
LOG_DBG("ISO receive error");
7482
}
7583

7684
if (info->flags & BT_ISO_FLAGS_LOST) {
77-
log_stream_rx(stream, info, buf);
78-
LOG_DBG("ISO receive lost\n");
7985
stream->reporting_info.loss_cnt++;
86+
do_log = true;
87+
LOG_DBG("ISO receive lost");
8088
}
8189

8290
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
8795
}
8896
}
8997

98+
if (do_log) {
99+
log_stream_rx(stream, info, buf);
100+
}
101+
90102
stream->reporting_info.last_seq_num = info->seq_num;
91103
stream->reporting_info.last_ts = info->ts;
92-
stream->reporting_info.recv_cnt++;
93104
#endif /* CONFIG_INFO_REPORTING_INTERVAL > 0 */
94105

95106
total_rx_iso_packet_count++;

0 commit comments

Comments
 (0)