diff --git a/example/hfp_hf_demo.c b/example/hfp_hf_demo.c index 72634d761..48b0b6548 100644 --- a/example/hfp_hf_demo.c +++ b/example/hfp_hf_demo.c @@ -143,11 +143,11 @@ static void show_usage(void){ printf("U - end active call and accept other call' (TWC 1)\n"); printf("v - Swap active call call (TWC 2) | V - Join held call (TWC 3)\n"); printf("w - Connect calls (TWC 4) | W - redial\n"); + printf("m - deactivate echo canceling and noise reduction\n"); printf("c/C - disable/enable registration status update for all AG indicators\n"); printf("e/E - disable/enable reporting of the extended AG error result code\n"); printf("k/K - deactivate/activate call waiting notification\n"); printf("l/L - deactivate/activate calling line notification\n"); - printf("m/M - deactivate/activate echo canceling and noise reduction\n"); printf("n/N - deactivate/activate voice recognition\n"); printf("z/Z - deactivate/activate enhanced voice recognition\n"); printf("h - start new audio enhanced voice recognition session\n"); @@ -302,11 +302,6 @@ static void stdin_process(char c){ printf("Deactivate echo canceling and noise reduction\n"); status = hfp_hf_deactivate_echo_canceling_and_noise_reduction(acl_handle); break; - case 'M': - log_info("USER:\'%c\'", cmd); - printf("Activate echo canceling and noise reduction\n"); - status = hfp_hf_activate_echo_canceling_and_noise_reduction(acl_handle); - break; case 'n': log_info("USER:\'%c\'", cmd); printf("Deactivate voice recognition\n"); diff --git a/src/classic/hfp_ag.h b/src/classic/hfp_ag.h index 1453f9dc4..23a20a51d 100644 --- a/src/classic/hfp_ag.h +++ b/src/classic/hfp_ag.h @@ -268,7 +268,7 @@ uint8_t hfp_ag_notify_incoming_call_waiting(hci_con_handle_t acl_handle); * @param acl_handle * @return status ERROR_CODE_SUCCESS if successful, otherwise: * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or - * - ERROR_CODE_COMMAND_DISALLOWED if AG or HF does not support voice recognition, or already activated + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_VOICE_RECOGNITION_FUNCTION is not supported by HF and AG, or already activated */ uint8_t hfp_ag_activate_voice_recognition(hci_con_handle_t acl_handle); @@ -280,7 +280,7 @@ uint8_t hfp_ag_activate_voice_recognition(hci_con_handle_t acl_handle); * @param acl_handle * @return status ERROR_CODE_SUCCESS if successful, otherwise: * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or - * - ERROR_CODE_COMMAND_DISALLOWED if AG or HF does not support voice recognition, or already deactivated + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_VOICE_RECOGNITION_FUNCTION is not supported by HF and AG, or already deactivated */ uint8_t hfp_ag_deactivate_voice_recognition(hci_con_handle_t acl_handle); @@ -293,7 +293,7 @@ uint8_t hfp_ag_deactivate_voice_recognition(hci_con_handle_t acl_handle); * @param activate * @return status ERROR_CODE_SUCCESS if successful, otherwise: * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or - * - ERROR_CODE_COMMAND_DISALLOWED if AG or HF does not support enhanced voice recognition + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG */ uint8_t hfp_ag_activate_enhanced_voice_recognition(hci_con_handle_t acl_handle); @@ -305,7 +305,7 @@ uint8_t hfp_ag_activate_enhanced_voice_recognition(hci_con_handle_t acl_handle); * @param activate * @return status ERROR_CODE_SUCCESS if successful, otherwise: * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or - * - ERROR_CODE_COMMAND_DISALLOWED if AG or HF does not support enhanced voice recognition + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG */ uint8_t hfp_ag_enhanced_voice_recognition_report_sending_audio(hci_con_handle_t acl_handle); @@ -317,7 +317,7 @@ uint8_t hfp_ag_enhanced_voice_recognition_report_sending_audio(hci_con_handle_t * @param activate * @return status ERROR_CODE_SUCCESS if successful, otherwise: * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or - * - ERROR_CODE_COMMAND_DISALLOWED if AG or HF does not support enhanced voice recognition + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG */ uint8_t hfp_ag_enhanced_voice_recognition_report_ready_for_audio(hci_con_handle_t acl_handle); @@ -329,7 +329,7 @@ uint8_t hfp_ag_enhanced_voice_recognition_report_ready_for_audio(hci_con_handle_ * @param activate * @return status ERROR_CODE_SUCCESS if successful, otherwise: * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or - * - ERROR_CODE_COMMAND_DISALLOWED if AG or HF does not support enhanced voice recognition + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG */ uint8_t hfp_ag_enhanced_voice_recognition_report_processing_input(hci_con_handle_t acl_handle); @@ -341,7 +341,7 @@ uint8_t hfp_ag_enhanced_voice_recognition_report_processing_input(hci_con_handle * @param activate * @return status ERROR_CODE_SUCCESS if successful, otherwise: * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or - * - ERROR_CODE_COMMAND_DISALLOWED if AG or HF does not support enhanced voice recognition + * - ERROR_CODE_COMMAND_DISALLOWED if HF and AG do not support features: HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS and HFP_(HF/AG)SF_VOICE_RECOGNITION_TEXT */ uint8_t hfp_ag_enhanced_voice_recognition_send_message(hci_con_handle_t acl_handle, hfp_voice_recognition_state_t state, hfp_voice_recognition_message_t msg); @@ -354,7 +354,7 @@ uint8_t hfp_ag_enhanced_voice_recognition_send_message(hci_con_handle_t acl_hand * @param activate * @return status ERROR_CODE_SUCCESS if successful, otherwise: * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or - * - ERROR_CODE_COMMAND_DISALLOWED if AG or HF does not support enhanced voice recognition + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG */ uint8_t hfp_ag_deactivate_enhanced_voice_recognition(hci_con_handle_t acl_handle); diff --git a/src/classic/hfp_hf.c b/src/classic/hfp_hf.c index c42834730..59f5f5294 100644 --- a/src/classic/hfp_hf.c +++ b/src/classic/hfp_hf.c @@ -1758,16 +1758,10 @@ uint8_t hfp_hf_deactivate_calling_line_notification(hci_con_handle_t acl_handle) return ERROR_CODE_SUCCESS; } - -uint8_t hfp_hf_activate_echo_canceling_and_noise_reduction(hci_con_handle_t acl_handle){ - hfp_connection_t * hfp_connection = get_hfp_hf_connection_context_for_acl_handle(acl_handle); - if (!hfp_connection) { - return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; - } - - hfp_connection->hf_activate_echo_canceling_and_noise_reduction = 1; - hfp_hf_run_for_context(hfp_connection); - return ERROR_CODE_SUCCESS; +static bool hfp_hf_echo_canceling_and_noise_reduction_supported(hfp_connection_t * hfp_connection){ + int ag = get_bit(hfp_connection->remote_supported_features, HFP_AGSF_EC_NR_FUNCTION); + int hf = get_bit(hfp_supported_features, HFP_HFSF_EC_NR_FUNCTION); + return hf && ag; } uint8_t hfp_hf_deactivate_echo_canceling_and_noise_reduction(hci_con_handle_t acl_handle){ @@ -1775,7 +1769,10 @@ uint8_t hfp_hf_deactivate_echo_canceling_and_noise_reduction(hci_con_handle_t ac if (!hfp_connection) { return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; } - + if (!hfp_hf_echo_canceling_and_noise_reduction_supported(hfp_connection)){ + return ERROR_CODE_COMMAND_DISALLOWED; + } + hfp_connection->hf_deactivate_echo_canceling_and_noise_reduction = 1; hfp_hf_run_for_context(hfp_connection); return ERROR_CODE_SUCCESS; diff --git a/src/classic/hfp_hf.h b/src/classic/hfp_hf.h index a8602423a..341659f63 100644 --- a/src/classic/hfp_hf.h +++ b/src/classic/hfp_hf.h @@ -344,22 +344,15 @@ uint8_t hfp_hf_deactivate_calling_line_notification(hci_con_handle_t acl_handle) /* - * @brief Activate echo canceling and noise reduction in the AG. By default, - * if the AG supports its own embedded echo canceling and/or noise reduction - * functions, it shall have them activated until this function is called. - * If the AG does not support any echo canceling and noise reduction functions, - * it shall respond with the ERROR indicator (TODO) + * @brief Deactivate echo canceling (EC) and noise reduction (NR) in the AG and emit + * HFP_SUBEVENT_ECHO_CANCELING_NOISE_REDUCTION_DEACTIVATE with status ERROR_CODE_SUCCESS if AG supports EC and AG. + * If the AG supports its own embedded echo canceling and/or noise reduction function, + * it shall have EC and NR activated until this function is called. * * @param acl_handle - * @return status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist - */ -uint8_t hfp_hf_activate_echo_canceling_and_noise_reduction(hci_con_handle_t acl_handle); - -/* - * @brief Deactivate echo canceling and noise reduction in the AG. - * - * @param acl_handle - * @return status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist + * @return status ERROR_CODE_SUCCESS if successful, otherwise: + * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or + * - ERROR_CODE_COMMAND_DISALLOWED if HFP_(HF/AG)SF_EC_NR_FUNCTION feature is not supported by AG and HF */ uint8_t hfp_hf_deactivate_echo_canceling_and_noise_reduction(hci_con_handle_t acl_handle); @@ -371,7 +364,7 @@ uint8_t hfp_hf_deactivate_echo_canceling_and_noise_reduction(hci_con_handle_t ac * @param acl_handle * @return status ERROR_CODE_SUCCESS if successful, otherwise: * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or - * - ERROR_CODE_COMMAND_DISALLOWED if AG or HF does not support voice recognition, or already activated + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_VOICE_RECOGNITION_FUNCTION is not supported by HF and AG, or already activated */ uint8_t hfp_hf_activate_voice_recognition(hci_con_handle_t acl_handle); @@ -383,7 +376,7 @@ uint8_t hfp_hf_activate_voice_recognition(hci_con_handle_t acl_handle); * @param acl_handle * @return status ERROR_CODE_SUCCESS if successful, otherwise: * - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or - * - ERROR_CODE_COMMAND_DISALLOWED if AG or HF does not support voice recognition, or already activated + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_VOICE_RECOGNITION_FUNCTION is not supported by HF and AG, or already activated */ uint8_t hfp_hf_deactivate_voice_recognition(hci_con_handle_t acl_handle); @@ -394,7 +387,7 @@ uint8_t hfp_hf_deactivate_voice_recognition(hci_con_handle_t acl_handle); * * @param acl_handle * @return status ERROR_CODE_SUCCESS if successful, otherwise: - * - ERROR_CODE_COMMAND_DISALLOWED if HF does not support it, or wrong VRA status + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG, or wrong VRA status */ uint8_t hfp_hf_activate_enhanced_voice_recognition(hci_con_handle_t acl_handle); @@ -406,7 +399,7 @@ uint8_t hfp_hf_activate_enhanced_voice_recognition(hci_con_handle_t acl_handle); * * @param acl_handle * @return status ERROR_CODE_SUCCESS if successful, otherwise: - * - ERROR_CODE_COMMAND_DISALLOWED if HF does not support it, or wrong VRA status + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG, or wrong VRA status */ uint8_t hfp_hf_enhanced_voice_recognition_report_ready_for_audio(hci_con_handle_t acl_handle); @@ -417,7 +410,7 @@ uint8_t hfp_hf_enhanced_voice_recognition_report_ready_for_audio(hci_con_handle_ * * @param acl_handle * @return status ERROR_CODE_SUCCESS if successful, otherwise: - * - ERROR_CODE_COMMAND_DISALLOWED if HF does not support it, or wrong VRA status + * - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG, or wrong VRA status */ uint8_t hfp_hf_deactivate_enhanced_voice_recognition(hci_con_handle_t acl_handle); diff --git a/test/hfp/hfp_hf_client_test.c b/test/hfp/hfp_hf_client_test.c index f3b4ae7a3..460125d26 100644 --- a/test/hfp/hfp_hf_client_test.c +++ b/test/hfp/hfp_hf_client_test.c @@ -195,10 +195,6 @@ static void user_command(char cmd){ printf("Deactivate echo canceling and noise reduction\n"); hfp_hf_deactivate_echo_canceling_and_noise_reduction(acl_handle); break; - case 'M': - printf("Activate echo canceling and noise reduction\n"); - hfp_hf_activate_echo_canceling_and_noise_reduction(acl_handle); - break; case 'n': printf("Deactivate voice recognition\n"); hfp_hf_deactivate_voice_recognition(acl_handle); diff --git a/test/pts/hfp_hf_test.c b/test/pts/hfp_hf_test.c index 465d6b8ce..767c816be 100644 --- a/test/pts/hfp_hf_test.c +++ b/test/pts/hfp_hf_test.c @@ -141,11 +141,11 @@ static void show_usage(void){ printf("U - end active call and accept other call' (TWC 1)\n"); printf("v - Swap active call call (TWC 2) | V - Join held call (TWC 3)\n"); printf("w - Connect calls (TWC 4) | W - redial\n"); + printf("m - deactivate echo canceling and noise reduction\n"); printf("c/C - disable/enable registration status update for all AG indicators\n"); printf("e/E - disable/enable reporting of the extended AG error result code\n"); printf("k/K - deactivate/activate call waiting notification\n"); printf("l/L - deactivate/activate calling line notification\n"); - printf("m/M - deactivate/activate echo canceling and noise reduction\n"); printf("n/N - deactivate/activate voice recognition\n"); printf("r/R - deactivate/activate enhanced voice recognition\n"); printf("0123456789#*-+ - send DTMF dial tones\n"); @@ -296,11 +296,6 @@ static void stdin_process(char c){ printf("Deactivate echo canceling and noise reduction\n"); hfp_hf_deactivate_echo_canceling_and_noise_reduction(acl_handle); break; - case 'M': - log_info("USER:\'%c\'", cmd); - printf("Activate echo canceling and noise reduction\n"); - hfp_hf_activate_echo_canceling_and_noise_reduction(acl_handle); - break; case 'n': log_info("USER:\'%c\'", cmd); printf("Deactivate voice recognition\n");