Commit 7048b0fa authored by Vinayak Kariappa Chettimada's avatar Vinayak Kariappa Chettimada Committed by David Leach
Browse files

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: default avatarVinayak Kariappa Chettimada <vich@nordicsemi.no>
parent eb180052
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -8,9 +8,9 @@
#include <zephyr/bluetooth/iso.h>
#include <zephyr/sys/byteorder.h>

#define BUF_ALLOC_TIMEOUT (10) /* milliseconds */
#define BIG_TERMINATE_TIMEOUT_US (60 * USEC_PER_SEC) /* microseconds */
#define BIG_SDU_INTERVAL_US      (10000)
#define BUF_ALLOC_TIMEOUT_US     (BIG_SDU_INTERVAL_US * 2U) /* milliseconds */
#define BIG_TERMINATE_TIMEOUT_US (60 * USEC_PER_SEC) /* microseconds */

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

			buf = net_buf_alloc(&bis_tx_pool,
					    K_MSEC(BUF_ALLOC_TIMEOUT));
			buf = net_buf_alloc(&bis_tx_pool, K_USEC(BUF_ALLOC_TIMEOUT_US));
			if (!buf) {
				printk("Data buffer allocate timeout on channel"
				       " %u\n", chan);
				return 0;
			}

			ret = k_sem_take(&sem_iso_data,
					 K_MSEC(BUF_ALLOC_TIMEOUT));
			ret = k_sem_take(&sem_iso_data, K_USEC(BUF_ALLOC_TIMEOUT_US));
			if (ret) {
				printk("k_sem_take for ISO data sent failed\n");
				net_buf_unref(buf);