hfp_ag: extract hfp_ag_vra_send_command

This commit is contained in:
Matthias Ringwald 2021-08-29 11:13:23 +02:00
parent 774e3016a5
commit 08dc7cc656

View File

@ -797,6 +797,9 @@ static bool hfp_ag_can_activate_voice_recognition(hfp_connection_t * hfp_connect
if (hfp_connection->vra_state != HFP_VRA_VOICE_RECOGNITION_OFF){
return false;
}
if (hfp_connection->ag_vra_send_command){
return false;
}
return true;
}
@ -915,15 +918,10 @@ static uint8_t hfp_ag_vra_state_machine_two(hfp_connection_t * hfp_connection){
return status;
}
static int hfp_ag_voice_recognition_state_machine(hfp_connection_t * hfp_connection){
if (hfp_connection->state < HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) {
return 0;
}
int done = 0;
static uint8_t hfp_ag_vra_send_command(hfp_connection_t * hfp_connection){
uint8_t done = 0;
uint8_t status;
switch (hfp_connection->command){
case HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION:
switch (hfp_connection->vra_state_requested){
case HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_MSG:
done = hfp_ag_send_enhanced_voice_recognition_msg_cmd(hfp_connection);
@ -958,13 +956,26 @@ static int hfp_ag_voice_recognition_state_machine(hfp_connection_t * hfp_connect
}
return 0;
}
break;
status = hfp_ag_vra_state_machine_two(hfp_connection);
return (status == ERROR_CODE_SUCCESS) ? 1 : 0;
default:
log_error("state %u", hfp_connection->vra_state_requested);
btstack_assert(false);
break;
return 0;
}
break;
}
static int hfp_ag_voice_recognition_state_machine(hfp_connection_t * hfp_connection){
if (hfp_connection->state < HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) {
return 0;
}
int done = 0;
uint8_t status;
switch (hfp_connection->command){
case HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION:
return hfp_ag_vra_send_command(hfp_connection);
case HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION:
// HF initiatied voice recognition, parser extracted activation value