From 5fc207996348d6fd31d8580ccabcf5a799bc8b81 Mon Sep 17 00:00:00 2001 From: Mariusz Skamra Date: Thu, 8 Dec 2022 17:17:15 +0100 Subject: [PATCH] Bluetooth: audio: ascs: Handle CIS failed to be established error In case CIS failed to be established, leave the ASE in enabling state waiting for peer to retry. Signed-off-by: Mariusz Skamra --- subsys/bluetooth/audio/ascs.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/audio/ascs.c b/subsys/bluetooth/audio/ascs.c index cdc29ca661f..af297704be9 100644 --- a/subsys/bluetooth/audio/ascs.c +++ b/subsys/bluetooth/audio/ascs.c @@ -530,6 +530,7 @@ static void ascs_ep_iso_disconnected(struct bt_audio_ep *ep, uint8_t reason) { const struct bt_audio_stream_ops *ops; struct bt_audio_stream *stream; + int err; stream = ep->stream; if (stream == NULL) { @@ -541,6 +542,18 @@ static void ascs_ep_iso_disconnected(struct bt_audio_ep *ep, uint8_t reason) LOG_DBG("stream %p ep %p reason 0x%02x", stream, stream->ep, reason); + if (ep->status.state == BT_AUDIO_EP_STATE_ENABLING && + reason == BT_HCI_ERR_CONN_FAIL_TO_ESTAB) { + LOG_DBG("Waiting for retry"); + + err = bt_audio_stream_iso_listen(stream); + if (err != 0) { + LOG_ERR("Could not make stream listen: %d", err); + } + + return; + } + if (ops != NULL && ops->stopped != NULL) { ops->stopped(stream); } else { @@ -553,8 +566,6 @@ static void ascs_ep_iso_disconnected(struct bt_audio_ep *ep, uint8_t reason) /* Trigger a call to ase_process to handle the cleanup */ k_work_submit(&ep->work); } else { - int err; - /* The ASE state machine goes into different states from this operation * based on whether it is a source or a sink ASE. */