Bluetooth: Introduce a timeout for synchronous HCI command sending
There is no command that should take more than a couple of seconds. If it does there's something severely wrong with the system. Catch such situations with a clear assert rather than silently blocking the sending thread. Change-Id: Ie981fddcc27059df3e4df586e86ceac2e348f509 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
a20464727f
commit
e2eb446b7b
1 changed files with 4 additions and 1 deletions
|
@ -45,6 +45,8 @@
|
|||
#define CONN_UPDATE_TIMEOUT K_SECONDS(5)
|
||||
#define RPA_TIMEOUT K_SECONDS(CONFIG_BLUETOOTH_RPA_TIMEOUT)
|
||||
|
||||
#define HCI_CMD_TIMEOUT K_SECONDS(10)
|
||||
|
||||
/* Stacks for the threads */
|
||||
#if !defined(CONFIG_BLUETOOTH_RECV_IS_RX_THREAD)
|
||||
static BT_STACK_NOINIT(rx_thread_stack, CONFIG_BLUETOOTH_RX_STACK_SIZE);
|
||||
|
@ -229,7 +231,8 @@ int bt_hci_cmd_send_sync(uint16_t opcode, struct net_buf *buf,
|
|||
|
||||
net_buf_put(&bt_dev.cmd_tx_queue, buf);
|
||||
|
||||
k_sem_take(&sync_sem, K_FOREVER);
|
||||
err = k_sem_take(&sync_sem, HCI_CMD_TIMEOUT);
|
||||
__ASSERT(err == 0, "k_sem_take failed with err %d", err);
|
||||
|
||||
BT_DBG("opcode 0x%04x status 0x%02x", opcode, cmd(buf)->status);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue