From bdc8377d3a4038bb421aca62a407b1279c435069 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 3 Apr 2025 14:44:23 +0200 Subject: [PATCH] avdtp: SEP discovery for incoming AVDTP connection after outgoing connection was triggered --- CHANGELOG.md | 1 + src/classic/avdtp.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13ebed088..c4142bfb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - BNEP: emit channel opened with ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION if connection cannot be set up - HFP AG: avoid recursion with synchronous HCI transport - HFP HF: send Apple Accessory information after service level connection +- AVDTP: SEP discovery for incoming AVDTP connection after outgoing connection was triggered ### Changed - HCI: hci_request_cis_can_send_now_events for CIG in Central role will emit can send now events for all streams in group diff --git a/src/classic/avdtp.c b/src/classic/avdtp.c index 972f8e11f..74917f66e 100644 --- a/src/classic/avdtp.c +++ b/src/classic/avdtp.c @@ -691,13 +691,17 @@ static void avdtp_finalize_connection(avdtp_connection_t * connection){ btstack_memory_avdtp_connection_free(connection); } -static void avdtp_start_sep_query(avdtp_connection_t * connection, bool have_get_all_capabilities) { - if (have_get_all_capabilities){ - connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES; +static void avdtp_start_sep_query_if_idle(avdtp_connection_t * connection, bool have_get_all_capabilities) { + if (connection->acceptor_connection_state == AVDTP_SIGNALING_CONNECTION_ACCEPTOR_IDLE) { + if (have_get_all_capabilities){ + connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES; + } else { + connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES; + } + avdtp_request_can_send_now_initiator(connection); } else { - connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES; + log_info("avdtp_start_sep_query_if_idle: sep query already active"); } - avdtp_request_can_send_now_initiator(connection); } static void avdtp_handle_sdp_query_failed(avdtp_connection_t * connection, uint8_t status){ @@ -709,7 +713,7 @@ static void avdtp_handle_sdp_query_failed(avdtp_connection_t * connection, uint8 case AVDTP_SIGNALING_CONNECTION_OPENED: // SDP query failed: try query that must be supported - avdtp_start_sep_query(connection, false); + avdtp_start_sep_query_if_idle(connection, false); return; default: @@ -726,7 +730,7 @@ static void avdtp_handle_sdp_query_succeeded(avdtp_connection_t * connection){ switch (connection->state){ case AVDTP_SIGNALING_CONNECTION_OPENED: - avdtp_start_sep_query(connection, connection->avdtp_version >= 0x0103); + avdtp_start_sep_query_if_idle(connection, connection->avdtp_version >= 0x0103); break; default: connection->state = AVDTP_SIGNALING_CONNECTION_W4_L2CAP_CONNECTED;