Skip to content

Commit 7048b0f

Browse files
cvinayakdleach02
authored andcommitted
samples: Bluetooth: iso_broadcast: Fix buf alloc timeout
Fix buf alloc timeout to 20 millisecond as the sent callback can have a latency that is upto twice the ISO interval. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent eb18005 commit 7048b0f

File tree

1 file changed

+4
-6
lines changed
  • samples/bluetooth/iso_broadcast/src

1 file changed

+4
-6
lines changed

samples/bluetooth/iso_broadcast/src/main.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#include <zephyr/bluetooth/iso.h>
99
#include <zephyr/sys/byteorder.h>
1010

11-
#define BUF_ALLOC_TIMEOUT (10) /* milliseconds */
11+
#define BIG_SDU_INTERVAL_US (10000)
12+
#define BUF_ALLOC_TIMEOUT_US (BIG_SDU_INTERVAL_US * 2U) /* milliseconds */
1213
#define BIG_TERMINATE_TIMEOUT_US (60 * USEC_PER_SEC) /* microseconds */
13-
#define BIG_SDU_INTERVAL_US (10000)
1414

1515
#define BIS_ISO_CHAN_COUNT 2
1616
NET_BUF_POOL_FIXED_DEFINE(bis_tx_pool, BIS_ISO_CHAN_COUNT,
@@ -163,16 +163,14 @@ int main(void)
163163
struct net_buf *buf;
164164
int ret;
165165

166-
buf = net_buf_alloc(&bis_tx_pool,
167-
K_MSEC(BUF_ALLOC_TIMEOUT));
166+
buf = net_buf_alloc(&bis_tx_pool, K_USEC(BUF_ALLOC_TIMEOUT_US));
168167
if (!buf) {
169168
printk("Data buffer allocate timeout on channel"
170169
" %u\n", chan);
171170
return 0;
172171
}
173172

174-
ret = k_sem_take(&sem_iso_data,
175-
K_MSEC(BUF_ALLOC_TIMEOUT));
173+
ret = k_sem_take(&sem_iso_data, K_USEC(BUF_ALLOC_TIMEOUT_US));
176174
if (ret) {
177175
printk("k_sem_take for ISO data sent failed\n");
178176
net_buf_unref(buf);

0 commit comments

Comments
 (0)