From 8f8818a4bf38b28be09654d36383e17bd022d05b Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 29 Aug 2021 11:40:41 +0200 Subject: [PATCH] hfp_ag: use ag_vra_send_command instead of command for ag initiated vra commands --- src/classic/hfp.h | 5 +++-- src/classic/hfp_ag.c | 16 +++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/classic/hfp.h b/src/classic/hfp.h index 326dbfd1d..429de0173 100644 --- a/src/classic/hfp.h +++ b/src/classic/hfp.h @@ -648,7 +648,8 @@ typedef struct hfp_connection { uint8_t ag_response_and_hold_action; uint8_t ag_dtmf_code; bool ag_send_no_carrier; - + bool ag_vra_send_command; + int send_status_of_current_calls; int next_call_index; @@ -694,7 +695,7 @@ typedef struct hfp_connection { bool deactivate_voice_recognition; bool activate_voice_recognition; bool enhanced_voice_recognition_enabled; - + // ih HF, used by parser, in AG used for commands uint8_t ag_vra_status; hfp_voice_recognition_state_t ag_vra_state; diff --git a/src/classic/hfp_ag.c b/src/classic/hfp_ag.c index d1c8ce817..bca20a2f0 100644 --- a/src/classic/hfp_ag.c +++ b/src/classic/hfp_ag.c @@ -973,6 +973,12 @@ static int hfp_ag_voice_recognition_state_machine(hfp_connection_t * hfp_connect int done = 0; uint8_t status; + // VRA action initiated by AG + if (hfp_connection->ag_vra_send_command){ + hfp_connection->ag_vra_send_command = false; + return hfp_ag_vra_send_command(hfp_connection); + } + switch (hfp_connection->command){ case HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION: return hfp_ag_vra_send_command(hfp_connection); @@ -2851,10 +2857,10 @@ uint8_t hfp_ag_activate_voice_recognition(hci_con_handle_t acl_handle){ hfp_connection->ag_activate_voice_recognition_value = 1; hfp_connection->vra_state_requested = HFP_VRA_W2_SEND_VOICE_RECOGNITION_ACTIVATED; - hfp_connection->command = HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION; hfp_connection->enhanced_voice_recognition_enabled = enhanced_vra_supported; hfp_connection->ag_audio_connection_opened_before_vra = hfp_ag_is_audio_connection_active(hfp_connection); hfp_connection->ag_vra_state = HFP_VOICE_RECOGNITION_STATE_AG_READY; + hfp_connection->ag_vra_send_command = true; hfp_ag_run_for_context(hfp_connection); return ERROR_CODE_SUCCESS; } @@ -2878,8 +2884,8 @@ uint8_t hfp_ag_deactivate_voice_recognition(hci_con_handle_t acl_handle){ hfp_connection->ag_activate_voice_recognition_value = 0; hfp_connection->vra_state_requested = HFP_VRA_W2_SEND_VOICE_RECOGNITION_OFF; - hfp_connection->command = HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION; hfp_connection->ag_vra_state = HFP_VOICE_RECOGNITION_STATE_AG_READY; + hfp_connection->ag_vra_send_command = true; hfp_ag_run_for_context(hfp_connection); return ERROR_CODE_SUCCESS; } @@ -2903,9 +2909,9 @@ static uint8_t hfp_ag_enhanced_voice_recognition_send_state(hci_con_handle_t acl return ERROR_CODE_COMMAND_DISALLOWED; } - hfp_connection->command = HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION; hfp_connection->ag_vra_state = state; hfp_connection->vra_state_requested = HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_STATUS; + hfp_connection->ag_vra_send_command = true; hfp_ag_run_for_context(hfp_connection); return ERROR_CODE_SUCCESS; } @@ -2955,11 +2961,11 @@ uint8_t hfp_ag_enhanced_voice_recognition_send_message(hci_con_handle_t acl_hand return ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE; } - hfp_connection->command = HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION; hfp_connection->vra_state_requested = HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_MSG; hfp_connection->ag_msg = msg; hfp_connection->ag_vra_state = state; - hfp_ag_run_for_context(hfp_connection); + hfp_connection->ag_vra_send_command = true; + hfp_ag_run_for_context(hfp_connection); return ERROR_CODE_SUCCESS; }