From 9348a338e2d138f38f198a9c00ea9d0527a42b59 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 19 Nov 2015 20:55:46 +0100 Subject: [PATCH] add 'answer call on ag' and fix implementation --- src/hfp_ag.c | 12 +++++------- src/hfp_ag.h | 2 +- test/pts/hfp_ag_test.c | 11 ++++++++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/hfp_ag.c b/src/hfp_ag.c index 4b6c17ec8..76db312bc 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -648,7 +648,7 @@ static int incoming_call_state_machine(hfp_connection_t * context){ if (!context->run_call_state_machine) return 0; if (context->state < HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) return 0; - // printf(" -> State machine: Incoming Call\n"); + // printf(" -> State machine: Incoming Call, state %u, command %u\n", context->call_state, context->command); hfp_ag_indicator_t * indicator; if (context->command == HFP_CMD_HANG_UP_CALL){ context->terminate_call = 1; @@ -692,7 +692,7 @@ 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){ context->ag_ring = 0; @@ -703,9 +703,9 @@ static int incoming_call_state_machine(hfp_connection_t * context){ } context->ag_ring = 0; hfp_timeout_stop(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); + + // printf(" HFP_CALL_W4_ANSWER, cmd %d \n", context->command); if (context->command == HFP_CMD_CALL_ANSWERED){ context->call_state = HFP_CALL_TRANSFER_CALL_STATUS; hfp_ag_ok(context->rfcomm_cid); @@ -1002,14 +1002,12 @@ 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){ +void hfp_ag_answer_incoming_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); diff --git a/src/hfp_ag.h b/src/hfp_ag.h index 2a584530e..2fab3c0e9 100644 --- a/src/hfp_ag.h +++ b/src/hfp_ag.h @@ -175,7 +175,7 @@ void hfp_ag_incoming_call(void); /** * @brief */ - void hfp_ag_answer_incomming_call(void); + void hfp_ag_answer_incoming_call(void); /** * @brief diff --git a/test/pts/hfp_ag_test.c b/test/pts/hfp_ag_test.c index e75194df7..f5009f88a 100644 --- a/test/pts/hfp_ag_test.c +++ b/test/pts/hfp_ag_test.c @@ -116,12 +116,17 @@ static void show_usage(void){ printf("b - establish AUDIO connection\n"); printf("B - release AUDIO connection\n"); - printf("d - report AG failure\n"); printf("c - simulate incoming call\n"); printf("C - simulate terminage call\n"); + printf("d - report AG failure\n"); + + printf("e - answer call on AG\n"); + printf("r - disable in-band ring tone\n"); printf("R - enable in-band ring tone\n"); + + printf("t - terminate connection\n"); printf("---\n"); @@ -170,6 +175,10 @@ static int stdin_process(struct data_source *ds){ printf("Report AG failure\n"); hfp_ag_report_extended_audio_gateway_error_result_code(device_addr, HFP_CME_ERROR_AG_FAILURE); break; + case 'e': + printf("Answer call on AG\n"); + hfp_ag_answer_incoming_call(); + break; case 'r': printf("Disable in-band ring tone\n"); hfp_ag_set_use_in_band_ring_tone(0);