Skip to content

Commit 12fc1d9

Browse files
alexsvenkoffes
authored andcommitted
[nrf fromlist] 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 <[email protected]> (cherry picked from commit 6569214eb39f5b4847fa1c21fa6b10f2290f7e8c)
1 parent dc05376 commit 12fc1d9

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

tests/bluetooth/tester/src/audio/btp_bap_unicast.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -693,21 +693,21 @@ static void stream_started_cb(struct bt_bap_stream *stream)
693693
static void stream_connected_cb(struct bt_bap_stream *stream)
694694
{
695695
struct bt_conn_info conn_info;
696+
struct bt_bap_ep_info ep_info;
697+
int err;
696698

697699
LOG_DBG("Connected stream %p", stream);
698700

699-
(void)bt_conn_get_info(stream->conn, &conn_info);
700-
if (conn_info.role == BT_HCI_ROLE_CENTRAL) {
701-
struct bt_bap_ep_info ep_info;
702-
int err;
701+
err = bt_bap_ep_get_info(stream->ep, &ep_info);
702+
if (err != 0) {
703+
LOG_ERR("Failed to get info: %d", err);
703704

704-
err = bt_bap_ep_get_info(stream->ep, &ep_info);
705-
if (err != 0) {
706-
LOG_ERR("Failed to get info: %d", err);
705+
return;
706+
}
707707

708-
return;
709-
}
708+
(void)bt_conn_get_info(stream->conn, &conn_info);
710709

710+
if (conn_info.role == BT_HCI_ROLE_CENTRAL) {
711711
if (ep_info.dir == BT_AUDIO_DIR_SOURCE) {
712712
if (ep_info.state == BT_BAP_EP_STATE_ENABLING) {
713713
/* Automatically do the receiver start ready operation for source
@@ -727,6 +727,18 @@ static void stream_connected_cb(struct bt_bap_stream *stream)
727727
BT_ASCS_START_OP,
728728
BTP_ASCS_STATUS_SUCCESS);
729729
}
730+
} else {
731+
if (ep_info.dir == BT_AUDIO_DIR_SINK && ep_info.state == BT_BAP_EP_STATE_ENABLING) {
732+
/* Automatically do the receiver start ready operation for sink
733+
* ASEs as the server when in the enabling state.
734+
* The CIS may be connected in the QoS Configured state as well, in
735+
* which case we should wait until we enter the enabling state.
736+
*/
737+
err = bt_bap_stream_start(stream);
738+
if (err != 0) {
739+
LOG_ERR("Failed to start stream %p", stream);
740+
}
741+
}
730742
}
731743

732744
btp_send_ascs_cis_connected_ev(stream);

0 commit comments

Comments
 (0)