diff --git a/src/classic/hfp.c b/src/classic/hfp.c index bed260661..5ee876bdf 100644 --- a/src/classic/hfp.c +++ b/src/classic/hfp.c @@ -539,7 +539,7 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet hci_event_connection_request_get_bd_addr(packet, event_addr); hfp_connection = get_hfp_connection_context_for_bd_addr(event_addr); if (!hfp_connection) break; - hfp_connection->ag_establish_SCO = 1; + hfp_connection->hf_accept_sco = 1; default: break; } @@ -607,10 +607,10 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet log_error("HFP: connection does not exist for remote with addr %s.", bd_addr_to_str(event_addr)); return; } - hfp_connection->ag_establish_SCO = 0; status = hci_event_synchronous_connection_complete_get_status(packet); if (status != 0){ + hfp_connection->hf_accept_sco = 0; hfp_handle_failed_sco_connection(status); break; } diff --git a/src/classic/hfp.h b/src/classic/hfp.h index ae331983d..b41f43a58 100644 --- a/src/classic/hfp.h +++ b/src/classic/hfp.h @@ -561,7 +561,6 @@ typedef struct hfp_connection { uint8_t send_response_and_hold_status; // 0 - don't send. BRTH:0 == 1, .. // AG only - uint8_t ag_establish_SCO; uint8_t change_in_band_ring_tone_setting; uint8_t ag_ring; uint8_t ag_send_clip; @@ -575,6 +574,7 @@ typedef struct hfp_connection { int next_call_index; // HF only + uint8_t hf_accept_sco; hfp_hf_query_operator_state_t hf_query_operator_state; uint8_t hf_answer_incoming_call; uint8_t hf_initiate_outgoing_call; diff --git a/src/classic/hfp_hf.c b/src/classic/hfp_hf.c index 1c23b9394..1f657555a 100644 --- a/src/classic/hfp_hf.c +++ b/src/classic/hfp_hf.c @@ -582,7 +582,9 @@ static void hfp_run_for_context(hfp_connection_t * hfp_connection){ if (!hfp_connection) return; if (!hfp_connection->rfcomm_cid) return; - if (hfp_connection->ag_establish_SCO && hci_can_send_command_packet_now()){ + if (hfp_connection->hf_accept_sco && hci_can_send_command_packet_now()){ + + hfp_connection->hf_accept_sco = 0; // notify about codec selection if not done already if (hfp_connection->negotiated_codec == 0){ @@ -611,7 +613,7 @@ static void hfp_run_for_context(hfp_connection_t * hfp_connection){ sco_voice_setting = 0x0043; // Transparent data } - log_info("HFP: sending hci_accept_connection_request, sco_voice_setting %02x", sco_voice_setting); + log_info("HFP: sending hci_accept_connection_request, sco_voice_setting 0x%02x", sco_voice_setting); hci_send_cmd(&hci_accept_synchronous_connection, hfp_connection->remote_addr, 8000, 8000, max_latency, sco_voice_setting, retransmission_effort, packet_types); return; diff --git a/src/classic/hsp_ag.c b/src/classic/hsp_ag.c index 7d5557a11..7b0d0fbb5 100644 --- a/src/classic/hsp_ag.c +++ b/src/classic/hsp_ag.c @@ -92,7 +92,7 @@ static uint8_t ag_send_ok = 0; static uint8_t ag_send_error = 0; static uint8_t ag_num_button_press_received = 0; static uint8_t ag_support_custom_commands = 0; -static uint8_t ag_establish_SCO = 0; +static uint8_t ag_establish_sco = 0; static uint8_t hsp_disconnect_rfcomm = 0; static uint8_t hsp_establish_audio_connection = 0; static uint8_t hsp_release_audio_connection = 0; @@ -381,7 +381,9 @@ void hsp_ag_stop_ringing(void){ } static void hsp_run(void){ - if (ag_establish_SCO && hci_can_send_command_packet_now()){ + if (ag_establish_sco && hci_can_send_command_packet_now()){ + ag_establish_sco = 0; + log_info("HSP: sending hci_accept_connection_request."); // remote supported feature eSCO is set if link type is eSCO // eSCO: S4 - max latency == transmission interval = 0x000c == 12 ms, @@ -586,10 +588,9 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack case HCI_EVENT_CONNECTION_REQUEST: printf("hsp HCI_EVENT_CONNECTION_REQUEST\n"); hci_event_connection_request_get_bd_addr(packet, sco_event_addr); - ag_establish_SCO = 1; + ag_establish_sco = 1; break; case HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE:{ - ag_establish_SCO = 0; uint8_t status = hci_event_synchronous_connection_complete_get_status(packet); if (status != 0){ log_error("(e)SCO Connection failed, status %u", status);