hfp_ag.c (135d971835adb84499692ca4520e9900085f7d67) | hfp_ag.c (553a4a561f786fff6050306fb8f8ca8e28d447d4) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 880 unchanged lines hidden (view full) --- 889 } 890 hfp_connection->vra_state_requested = hfp_connection->vra_state; 891 return done; 892 893 default: 894 done = hfp_ag_send_voice_recognition_cmd(hfp_connection, hfp_connection->ag_activate_voice_recognition_value); 895 if (done == 0){ 896 hfp_connection->vra_state_requested = hfp_connection->vra_state; | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 880 unchanged lines hidden (view full) --- 889 } 890 hfp_connection->vra_state_requested = hfp_connection->vra_state; 891 return done; 892 893 default: 894 done = hfp_ag_send_voice_recognition_cmd(hfp_connection, hfp_connection->ag_activate_voice_recognition_value); 895 if (done == 0){ 896 hfp_connection->vra_state_requested = hfp_connection->vra_state; |
897 hfp_emit_voice_recognition_state_event(hfp_connection, ERROR_CODE_COMMAND_DISALLOWED); | 897 898 if (hfp_connection->ag_activate_voice_recognition_value == 1){ 899 hfp_emit_voice_recognition_enabled(hfp_connection, done); 900 } else { 901 hfp_emit_voice_recognition_disabled(hfp_connection, done); 902 } |
898 return 0; 899 } 900 break; 901 } 902 break; 903 904 case HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION: 905 // HF initiatied voice recognition, parser extracted activation value --- 33 unchanged lines hidden (view full) --- 939 } 940 941 switch (hfp_connection->vra_state_requested){ 942 case HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO: 943 if (!hfp_ag_is_audio_connection_active(hfp_connection)){ 944 status = hfp_ag_setup_audio_connection(hfp_connection); 945 if (status != ERROR_CODE_SUCCESS){ 946 hfp_connection->vra_state_requested = hfp_connection->vra_state; | 903 return 0; 904 } 905 break; 906 } 907 break; 908 909 case HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION: 910 // HF initiatied voice recognition, parser extracted activation value --- 33 unchanged lines hidden (view full) --- 944 } 945 946 switch (hfp_connection->vra_state_requested){ 947 case HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO: 948 if (!hfp_ag_is_audio_connection_active(hfp_connection)){ 949 status = hfp_ag_setup_audio_connection(hfp_connection); 950 if (status != ERROR_CODE_SUCCESS){ 951 hfp_connection->vra_state_requested = hfp_connection->vra_state; |
947 hfp_emit_voice_recognition_state_event(hfp_connection, status); | 952 hfp_emit_voice_recognition_enabled(hfp_connection, status); |
948 return 0; 949 } 950 } 951 hfp_connection->enhanced_voice_recognition_enabled = true; 952 hfp_connection->vra_state = HFP_VRA_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO; 953 hfp_connection->vra_state_requested = hfp_connection->vra_state; 954 hfp_emit_enhanced_voice_recognition_hf_ready_for_audio_event(hfp_connection, ERROR_CODE_SUCCESS); 955 break; 956 957 case HFP_VRA_W2_SEND_VOICE_RECOGNITION_OFF: 958 hfp_connection->vra_state = HFP_VRA_VOICE_RECOGNITION_OFF; 959 hfp_connection->vra_state_requested = hfp_connection->vra_state; 960 961 // release audio connection only if it was opened after audio VR activated 962 if (hfp_ag_is_audio_connection_active(hfp_connection) && !hfp_connection->ag_audio_connection_opened_before_vra){ 963 hfp_trigger_release_audio_connection(hfp_connection); 964 } 965 | 953 return 0; 954 } 955 } 956 hfp_connection->enhanced_voice_recognition_enabled = true; 957 hfp_connection->vra_state = HFP_VRA_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO; 958 hfp_connection->vra_state_requested = hfp_connection->vra_state; 959 hfp_emit_enhanced_voice_recognition_hf_ready_for_audio_event(hfp_connection, ERROR_CODE_SUCCESS); 960 break; 961 962 case HFP_VRA_W2_SEND_VOICE_RECOGNITION_OFF: 963 hfp_connection->vra_state = HFP_VRA_VOICE_RECOGNITION_OFF; 964 hfp_connection->vra_state_requested = hfp_connection->vra_state; 965 966 // release audio connection only if it was opened after audio VR activated 967 if (hfp_ag_is_audio_connection_active(hfp_connection) && !hfp_connection->ag_audio_connection_opened_before_vra){ 968 hfp_trigger_release_audio_connection(hfp_connection); 969 } 970 |
966 hfp_emit_voice_recognition_state_event(hfp_connection, ERROR_CODE_SUCCESS); | 971 hfp_emit_voice_recognition_disabled(hfp_connection, ERROR_CODE_SUCCESS); |
967 break; 968 969 case HFP_VRA_W2_SEND_VOICE_RECOGNITION_ACTIVATED: 970 // open only if audio connection does not already exist 971 if (!hfp_ag_is_audio_connection_active(hfp_connection)){ 972 status = hfp_ag_setup_audio_connection(hfp_connection); 973 if (status != ERROR_CODE_SUCCESS){ 974 hfp_connection->vra_state_requested = hfp_connection->vra_state; | 972 break; 973 974 case HFP_VRA_W2_SEND_VOICE_RECOGNITION_ACTIVATED: 975 // open only if audio connection does not already exist 976 if (!hfp_ag_is_audio_connection_active(hfp_connection)){ 977 status = hfp_ag_setup_audio_connection(hfp_connection); 978 if (status != ERROR_CODE_SUCCESS){ 979 hfp_connection->vra_state_requested = hfp_connection->vra_state; |
975 hfp_emit_voice_recognition_state_event(hfp_connection, status); | 980 hfp_emit_voice_recognition_enabled(hfp_connection, status); |
976 return 0; 977 } 978 } 979 980 hfp_connection->vra_state = HFP_VRA_VOICE_RECOGNITION_ACTIVATED; 981 hfp_connection->vra_state_requested = hfp_connection->vra_state; | 981 return 0; 982 } 983 } 984 985 hfp_connection->vra_state = HFP_VRA_VOICE_RECOGNITION_ACTIVATED; 986 hfp_connection->vra_state_requested = hfp_connection->vra_state; |
982 hfp_emit_voice_recognition_state_event(hfp_connection, ERROR_CODE_SUCCESS); | 987 hfp_emit_voice_recognition_enabled(hfp_connection, ERROR_CODE_SUCCESS); |
983 break; 984 985 default: 986 break; 987 } 988 return done; 989} 990 --- 1823 unchanged lines hidden (view full) --- 2814 2815 if (!hfp_ag_can_activate_voice_recognition(hfp_connection)){ 2816 return ERROR_CODE_COMMAND_DISALLOWED; 2817 } 2818 2819 hfp_connection->ag_activate_voice_recognition_value = 1; 2820 hfp_connection->vra_state_requested = HFP_VRA_W2_SEND_VOICE_RECOGNITION_ACTIVATED; 2821 hfp_connection->command = HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION; | 988 break; 989 990 default: 991 break; 992 } 993 return done; 994} 995 --- 1823 unchanged lines hidden (view full) --- 2819 2820 if (!hfp_ag_can_activate_voice_recognition(hfp_connection)){ 2821 return ERROR_CODE_COMMAND_DISALLOWED; 2822 } 2823 2824 hfp_connection->ag_activate_voice_recognition_value = 1; 2825 hfp_connection->vra_state_requested = HFP_VRA_W2_SEND_VOICE_RECOGNITION_ACTIVATED; 2826 hfp_connection->command = HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION; |
2822 hfp_connection->enhanced_voice_recognition_enabled = enhanced_vra_supported; | 2827 // hfp_connection->enhanced_voice_recognition_enabled = enhanced_vra_supported; |
2823 hfp_connection->ag_audio_connection_opened_before_vra = hfp_ag_is_audio_connection_active(hfp_connection); 2824 hfp_connection->ag_vra_state = HFP_VOICE_RECOGNITION_STATE_AG_READY; 2825 hfp_ag_run_for_context(hfp_connection); 2826 return ERROR_CODE_SUCCESS; 2827} 2828 2829uint8_t hfp_ag_deactivate_voice_recognition(hci_con_handle_t acl_handle){ 2830 hfp_connection_t * hfp_connection = get_hfp_ag_connection_context_for_acl_handle(acl_handle); --- 227 unchanged lines hidden --- | 2828 hfp_connection->ag_audio_connection_opened_before_vra = hfp_ag_is_audio_connection_active(hfp_connection); 2829 hfp_connection->ag_vra_state = HFP_VOICE_RECOGNITION_STATE_AG_READY; 2830 hfp_ag_run_for_context(hfp_connection); 2831 return ERROR_CODE_SUCCESS; 2832} 2833 2834uint8_t hfp_ag_deactivate_voice_recognition(hci_con_handle_t acl_handle){ 2835 hfp_connection_t * hfp_connection = get_hfp_ag_connection_context_for_acl_handle(acl_handle); --- 227 unchanged lines hidden --- |