diff --git a/src/hfp.h b/src/hfp.h index 64fc0dc86..28ef28c06 100644 --- a/src/hfp.h +++ b/src/hfp.h @@ -157,6 +157,7 @@ typedef enum { HFP_CMD_AG_SUGGESTED_CODEC, HFP_CMD_HF_CONFIRMED_CODEC, HFP_CMD_CALL_ANSWERED, + HFP_CMD_AG_ANSWER_CALL, HFP_CMD_HANG_UP_CALL, HFP_CMD_CHANGE_IN_BAND_RING_TONE_SETTING } hfp_command_t; diff --git a/src/hfp_ag.c b/src/hfp_ag.c index 307a51d4b..051dccb51 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -684,7 +684,8 @@ static int incoming_call_state_machine(hfp_connection_t * context){ return 1; case HFP_CALL_W4_ANSWER: - if (context->command != HFP_CMD_CALL_ANSWERED) { + if (context->command != HFP_CMD_CALL_ANSWERED || + context->command != HFP_CMD_AG_ANSWER_CALL) { if (context->ag_ring){ hfp_ag_ring(context->rfcomm_cid); return 1; @@ -696,9 +697,20 @@ static int incoming_call_state_machine(hfp_connection_t * context){ //printf(" HFP_CALL_W4_ANSWER, cmd %d \n", context->command); context->call_state = HFP_CALL_TRANSFER_CALL_STATUS; hfp_emit_event(hfp_callback, HFP_SUBEVENT_STOP_RINGINIG, 0); - hfp_ag_ok(context->rfcomm_cid); - return 1; - + if (context->command == HFP_CMD_CALL_ANSWERED){ + context->call_state = HFP_CALL_TRANSFER_CALL_STATUS; + hfp_ag_ok(context->rfcomm_cid); + return 1; + } + if (context->command == HFP_CMD_AG_ANSWER_CALL) { + context->call_state = HFP_CALL_TRANSFER_CALLSETUP_STATUS; + indicator = get_ag_indicator_for_name("call"); + indicator->status = HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT; + hfp_ag_transfer_ag_indicators_status_cmd(context->rfcomm_cid, indicator); + return 1; + } + break; + case HFP_CALL_TRANSFER_CALL_STATUS: //printf(" HFP_CALL_TRANSFER_CALL_STATUS \n"); context->call_state = HFP_CALL_TRANSFER_CALLSETUP_STATUS; @@ -981,6 +993,20 @@ void hfp_ag_audio_connection_transfer_towards_ag(bd_addr_t bd_addr){ hfp_ag_release_audio_connection(bd_addr); } +void hfp_ag_answer_incomming_call(void){ + linked_list_iterator_t it; + linked_list_iterator_init(&it, hfp_get_connections()); + while (linked_list_iterator_has_next(&it)){ + hfp_connection_t * connection = (hfp_connection_t *)linked_list_iterator_next(&it); + if (connection->call_state != HFP_CALL_W4_ANSWER) continue; + + hfp_ag_establish_service_level_connection(connection->remote_addr); + connection->run_call_state_machine = 1; + connection->command = HFP_CMD_AG_ANSWER_CALL; + hfp_run_for_context(connection); + } +} + /** * @brief */ @@ -991,4 +1017,14 @@ void hfp_ag_audio_connection_transfer_towards_hf(bd_addr_t bd_addr){ hfp_ag_establish_audio_connection(bd_addr); } +void hfp_ag_place_a_call_with_phone_number(void){ + // linked_list_iterator_t it; + // linked_list_iterator_init(&it, hfp_get_connections()); + // while (linked_list_iterator_has_next(&it)){ + // hfp_connection_t * connection = (hfp_connection_t *)linked_list_iterator_next(&it); + // hfp_ag_establish_service_level_connection(connection->remote_addr); + // ... + // hfp_run_for_context(connection); + // } +} diff --git a/src/hfp_ag.h b/src/hfp_ag.h index 5a0ee2d75..2a584530e 100644 --- a/src/hfp_ag.h +++ b/src/hfp_ag.h @@ -172,6 +172,11 @@ void hfp_ag_set_use_in_band_ring_tone(int use_in_band_ring_tone); */ void hfp_ag_incoming_call(void); +/** + * @brief + */ + void hfp_ag_answer_incomming_call(void); + /** * @brief */ @@ -187,6 +192,11 @@ void hfp_ag_audio_connection_transfer_towards_hf(bd_addr_t bd_addr); */ void hfp_ag_audio_connection_transfer_towards_ag(bd_addr_t bd_addr); +/** + * @brief + */ +void hfp_ag_place_a_call_with_phone_number(void); + /* API_END */ #if defined __cplusplus