1
1
/*
2
- * Copyright (c) 2024 Nordic Semiconductor ASA
2
+ * Copyright (c) 2024-2025 Nordic Semiconductor ASA
3
3
*
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
20
20
#include <zephyr/logging/log.h>
21
21
#include <zephyr/logging/log_core.h>
22
22
#include <zephyr/net_buf.h>
23
+ #include <zephyr/sys/__assert.h>
23
24
#include <zephyr/sys/byteorder.h>
24
25
#include <zephyr/sys/util.h>
25
26
#include <zephyr/sys/util_macro.h>
@@ -79,6 +80,7 @@ static void tx_thread_func(void *arg1, void *arg2, void *arg3)
79
80
struct bt_bap_stream * bap_stream = tx_streams [i ].bap_stream ;
80
81
81
82
if (stream_is_streaming (bap_stream )) {
83
+ uint16_t sdu_len ;
82
84
struct net_buf * buf ;
83
85
84
86
buf = net_buf_alloc (& tx_pool , K_FOREVER );
@@ -88,12 +90,25 @@ static void tx_thread_func(void *arg1, void *arg2, void *arg3)
88
90
bap_stream -> codec_cfg -> id == BT_HCI_CODING_FORMAT_LC3 ) {
89
91
stream_lc3_add_data (& tx_streams [i ], buf );
90
92
} else {
93
+ __ASSERT (bap_stream -> qos -> sdu <= ARRAY_SIZE (mock_data ),
94
+ "Configured codec SDU len %u does not match mock "
95
+ "data size %zu" ,
96
+ bap_stream -> qos -> sdu , ARRAY_SIZE (mock_data ));
91
97
net_buf_add_mem (buf , mock_data , bap_stream -> qos -> sdu );
92
98
}
93
99
100
+ sdu_len = buf -> len ;
101
+
94
102
err = bt_bap_stream_send (bap_stream , buf , tx_streams [i ].seq_num );
95
103
if (err == 0 ) {
96
104
tx_streams [i ].seq_num ++ ;
105
+
106
+ if (CONFIG_INFO_REPORTING_INTERVAL > 0 &&
107
+ (tx_streams [i ].seq_num %
108
+ CONFIG_INFO_REPORTING_INTERVAL ) == 0U ) {
109
+ LOG_INF ("Stream %p: Sent %u total SDUs of size %u" ,
110
+ bap_stream , tx_streams [i ].seq_num , sdu_len );
111
+ }
97
112
} else {
98
113
LOG_ERR ("Unable to send: %d" , err );
99
114
net_buf_unref (buf );
@@ -131,6 +146,11 @@ int stream_tx_register(struct bt_bap_stream *bap_stream)
131
146
}
132
147
133
148
LOG_INF ("Registered %p for TX" , bap_stream );
149
+ if (bap_stream -> qos -> sdu > CONFIG_BT_ISO_TX_MTU ) {
150
+ LOG_WRN ("Stream configured for SDUs larger (%u) than "
151
+ "CONFIG_BT_ISO_TX_MTU (%d)" ,
152
+ bap_stream -> qos -> sdu , CONFIG_BT_ISO_TX_MTU );
153
+ }
134
154
135
155
return 0 ;
136
156
}
0 commit comments