Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: BAP: Add PSN debug log support #63607

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/zephyr/bluetooth/audio/bap.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ struct bt_bap_stream {
/** Stream user data */
void *user_data;

#if defined(CONFIG_BT_BAP_DEBUG_STREAM_SEQ_NUM)
uint16_t _prev_seq_num;
#endif /* CONFIG_BT_BAP_DEBUG_STREAM_SEQ_NUM */

/* Internally used list node */
sys_snode_t _node;
};
Expand Down
9 changes: 9 additions & 0 deletions subsys/bluetooth/audio/Kconfig.bap
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,14 @@ config BT_BAP_STREAM
default y if BT_ASCS || BT_BAP_UNICAST_CLIENT || \
BT_BAP_BROADCAST_SOURCE || BT_BAP_BROADCAST_SINK

config BT_BAP_DEBUG_STREAM_SEQ_NUM
bool "Bluetooth Audio Stream sequence number debug"
depends on BT_BAP_STREAM_LOG_LEVEL >= BT_BAP_STREAM_LOG_LEVEL_WRN
default y
help
Use this option to enable Bluetooth Audio Stream sequence number debugging logs for
the Bluetooth Audio functionality. This will provide a warning if the application
provides unexpected sequence numbers.

rsource "Kconfig.pacs"
rsource "Kconfig.ascs"
10 changes: 10 additions & 0 deletions subsys/bluetooth/audio/bap_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ int bt_bap_stream_send(struct bt_bap_stream *stream, struct net_buf *buf,
return -EBADMSG;
}

#if defined(CONFIG_BT_BAP_DEBUG_STREAM_SEQ_NUM)
if (stream->_prev_seq_num != 0U && seq_num != 0U &&
(stream->_prev_seq_num + 1U) != seq_num) {
LOG_WRN("Unexpected seq_num diff between %u and %u for %p", stream->_prev_seq_num,
seq_num, stream);
}

stream->_prev_seq_num = seq_num;
#endif /* CONFIG_BT_BAP_DEBUG_STREAM_SEQ_NUM */

/* TODO: Add checks for broadcast sink */

return bt_iso_chan_send(bt_bap_stream_iso_chan_get(stream),
Expand Down
Loading