From bc6cfd8917db19b9bfaefabe41a1ee4e47992800 Mon Sep 17 00:00:00 2001 From: Alexander Svensen Date: Thu, 27 Nov 2025 12:38:06 +0100 Subject: [PATCH] [nrf fromtree] tests: bluetooth: tester: Start stream from connected_cb - When we are a peripheral we want to be able to start a stream from the stream_connected_cb, given that we are in an enabling state and the stream is in the sink direction Signed-off-by: Alexander Svensen (cherry picked from commit f6cbd2f3a834c9f29d15ae0fb2f4abde6007e6ee) (cherry picked from commit ed09d97b549002e9534e23827b4e190ce6b1e40d) --- .../tester/src/audio/btp_bap_unicast.c | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/bluetooth/tester/src/audio/btp_bap_unicast.c b/tests/bluetooth/tester/src/audio/btp_bap_unicast.c index 449ac8076cae..c7c770ddca00 100644 --- a/tests/bluetooth/tester/src/audio/btp_bap_unicast.c +++ b/tests/bluetooth/tester/src/audio/btp_bap_unicast.c @@ -693,21 +693,21 @@ static void stream_started_cb(struct bt_bap_stream *stream) static void stream_connected_cb(struct bt_bap_stream *stream) { struct bt_conn_info conn_info; + struct bt_bap_ep_info ep_info; + int err; LOG_DBG("Connected stream %p", stream); - (void)bt_conn_get_info(stream->conn, &conn_info); - if (conn_info.role == BT_HCI_ROLE_CENTRAL) { - struct bt_bap_ep_info ep_info; - int err; + err = bt_bap_ep_get_info(stream->ep, &ep_info); + if (err != 0) { + LOG_ERR("Failed to get info: %d", err); - err = bt_bap_ep_get_info(stream->ep, &ep_info); - if (err != 0) { - LOG_ERR("Failed to get info: %d", err); + return; + } - return; - } + (void)bt_conn_get_info(stream->conn, &conn_info); + if (conn_info.role == BT_HCI_ROLE_CENTRAL) { if (ep_info.dir == BT_AUDIO_DIR_SOURCE) { if (ep_info.state == BT_BAP_EP_STATE_ENABLING) { /* Automatically do the receiver start ready operation for source @@ -727,6 +727,18 @@ static void stream_connected_cb(struct bt_bap_stream *stream) BT_ASCS_START_OP, BTP_ASCS_STATUS_SUCCESS); } + } else { + if (ep_info.dir == BT_AUDIO_DIR_SINK && ep_info.state == BT_BAP_EP_STATE_ENABLING) { + /* Automatically do the receiver start ready operation for sink + * ASEs as the server when in the enabling state. + * The CIS may be connected in the QoS Configured state as well, in + * which case we should wait until we enter the enabling state. + */ + err = bt_bap_stream_start(stream); + if (err != 0) { + LOG_ERR("Failed to start stream %p", stream); + } + } } btp_send_ascs_cis_connected_ev(stream);