hfp: emit call answered and terminated events

This commit is contained in:
Milanka Ringwald 2021-07-16 16:15:44 +02:00
parent a13ff7d155
commit 674ebed504
5 changed files with 26 additions and 9 deletions

View File

@ -160,7 +160,7 @@ static void show_usage(void){
printf("c - simulate incoming call from 1234567 | C - simulate call from 1234567 dropped\n"); printf("c - simulate incoming call from 1234567 | C - simulate call from 1234567 dropped\n");
printf("d - report AG failure\n"); printf("d - report AG failure\n");
printf("D - delete all link keys\n"); printf("D - delete all link keys\n");
printf("e - answer call on AG | E - reject call on AG\n"); printf("e - answer call on AG | E - terminate call on AG\n");
printf("r - disable in-band ring tone | R - enable in-band ring tone\n"); printf("r - disable in-band ring tone | R - enable in-band ring tone\n");
printf("f - Disable cellular network | F - Enable cellular network\n"); printf("f - Disable cellular network | F - Enable cellular network\n");
printf("g - Set signal strength to 0 | G - Set signal strength to 5\n"); printf("g - Set signal strength to 0 | G - Set signal strength to 5\n");
@ -247,7 +247,7 @@ static void stdin_process(char cmd){
break; break;
case 'E': case 'E':
log_info("USER:\'%c\'", cmd); log_info("USER:\'%c\'", cmd);
printf("Reject call on AG\n"); printf("Terminate call on AG\n");
hfp_ag_terminate_call(); hfp_ag_terminate_call();
break; break;
case 'f': case 'f':
@ -559,9 +559,15 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
hci_request_sco_can_send_now_event(); hci_request_sco_can_send_now_event();
} }
break; break;
case HFP_SUBEVENT_CALL_ANSWERED:
printf("Call answered\n");
break;
case HFP_SUBEVENT_CALL_TERMINATED: case HFP_SUBEVENT_CALL_TERMINATED:
printf("Call terminated\n"); printf("Call terminated\n");
break; break;
case HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED: case HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED:
printf("Audio connection released\n"); printf("Audio connection released\n");
sco_handle = HCI_CON_HANDLE_INVALID; sco_handle = HCI_CON_HANDLE_INVALID;
@ -595,14 +601,12 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
printf("Attach number to voice tag. Sending '1234567\n"); printf("Attach number to voice tag. Sending '1234567\n");
hfp_ag_send_phone_number_for_voice_tag(acl_handle, "1234567"); hfp_ag_send_phone_number_for_voice_tag(acl_handle, "1234567");
break; break;
case HFP_SUBEVENT_TRANSMIT_DTMF_CODES: case HFP_SUBEVENT_TRANSMIT_DTMF_CODES:
printf("Send DTMF Codes: '%s'\n", hfp_subevent_transmit_dtmf_codes_get_dtmf(event)); printf("Send DTMF Codes: '%s'\n", hfp_subevent_transmit_dtmf_codes_get_dtmf(event));
hfp_ag_send_dtmf_code_done(acl_handle); hfp_ag_send_dtmf_code_done(acl_handle);
break; break;
case HFP_SUBEVENT_CALL_ANSWERED:
printf("Call answered by HF\n");
break;
case HFP_SUBEVENT_VOICE_RECOGNITION_STATUS: case HFP_SUBEVENT_VOICE_RECOGNITION_STATUS:
status = hfp_subevent_voice_recognition_status_get_status(event); status = hfp_subevent_voice_recognition_status_get_status(event);
if (status != ERROR_CODE_SUCCESS){ if (status != ERROR_CODE_SUCCESS){

View File

@ -528,6 +528,11 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
hci_request_sco_can_send_now_event(); hci_request_sco_can_send_now_event();
} }
break; break;
case HFP_SUBEVENT_CALL_ANSWERED:
printf("Call answered\n");
break;
case HFP_SUBEVENT_CALL_TERMINATED: case HFP_SUBEVENT_CALL_TERMINATED:
printf("Call terminated\n"); printf("Call terminated\n");
break; break;

View File

@ -1634,7 +1634,6 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
default: default:
break; break;
} }
hfp_emit_simple_event(hfp_connection, HFP_SUBEVENT_CALL_TERMINATED);
break; break;
case HFP_AG_TERMINATE_CALL_BY_AG: case HFP_AG_TERMINATE_CALL_BY_AG:
@ -1823,6 +1822,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
hfp_ag_transfer_callheld_state(); hfp_ag_transfer_callheld_state();
} }
hfp_ag_hf_stop_ringing(hfp_connection); hfp_ag_hf_stop_ringing(hfp_connection);
hfp_emit_simple_event(hfp_connection, HFP_SUBEVENT_CALL_ANSWERED);
break; break;
} }

View File

@ -416,7 +416,7 @@ void hfp_ag_outgoing_call_ringing(void);
void hfp_ag_outgoing_call_established(void); void hfp_ag_outgoing_call_established(void);
/** /**
* @brief Pass the call droped event to the AG. * @brief Pass the call dropped event to the AG.
*/ */
void hfp_ag_call_dropped(void); void hfp_ag_call_dropped(void);

View File

@ -1189,7 +1189,15 @@ static void hfp_hf_handle_transfer_ag_indicator_status(hfp_connection_t * hfp_co
// avoid set but not used warning // avoid set but not used warning
(void) hfp_hf_callheld_status; (void) hfp_hf_callheld_status;
} else if (strcmp(hfp_connection->ag_indicators[i].name, "call") == 0){ } else if (strcmp(hfp_connection->ag_indicators[i].name, "call") == 0){
hfp_hf_call_status = (hfp_call_status_t) hfp_connection->ag_indicators[i].status; hfp_call_status_t new_hf_call_status = (hfp_call_status_t) hfp_connection->ag_indicators[i].status;
if (hfp_hf_call_status != new_hf_call_status){
if (new_hf_call_status == HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS){
hfp_emit_simple_event(hfp_connection, HFP_SUBEVENT_CALL_TERMINATED);
} else {
hfp_emit_simple_event(hfp_connection, HFP_SUBEVENT_CALL_ANSWERED);
}
}
hfp_hf_call_status = new_hf_call_status;
} }
hfp_connection->ag_indicators[i].status_changed = 0; hfp_connection->ag_indicators[i].status_changed = 0;
hfp_emit_ag_indicator_event(hfp_connection, &hfp_connection->ag_indicators[i]); hfp_emit_ag_indicator_event(hfp_connection, &hfp_connection->ag_indicators[i]);