From 56f716fecaed633ca0a83940a78e4baf031ca2a9 Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Fri, 27 Nov 2015 16:18:14 +0100 Subject: [PATCH] hfp: terminate/reject incoming call --- src/hfp_hf.c | 23 +++++++++++++++++++---- src/hfp_hf.h | 5 +++++ test/pts/hfp_hf_test.c | 6 ++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/hfp_hf.c b/src/hfp_hf.c index 6281dffae..53a438e8c 100644 --- a/src/hfp_hf.c +++ b/src/hfp_hf.c @@ -849,17 +849,32 @@ void hfp_hf_answer_incoming_call(bd_addr_t bd_addr){ if (hfp_callsetup_status == HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS){ connection->hf_answer_incoming_call = 1; + hfp_run_for_context(connection); } else { - log_error("HFP HF: answering incoming call in wrong callsetup state %u", hfp_callsetup_status); + log_error("HFP HF: answering incoming call with wrong callsetup status %u", hfp_callsetup_status); } - hfp_run_for_context(connection); } void hfp_hf_terminate_call(bd_addr_t bd_addr){ hfp_hf_establish_service_level_connection(bd_addr); hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr); - connection->hf_send_chup = 1; - hfp_run_for_context(connection); + + if (hfp_call_status == HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT){ + connection->hf_send_chup = 1; + hfp_run_for_context(connection); + } else { + log_error("HFP HF: terminating incoming call with wrong call status %u", hfp_call_status); + } +} + +void hfp_hf_reject_call(bd_addr_t bd_addr){ + hfp_hf_establish_service_level_connection(bd_addr); + hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr); + + if (hfp_callsetup_status == HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS){ + connection->hf_send_chup = 1; + hfp_run_for_context(connection); + } } void hfp_hf_enable_calling_line_identification(bd_addr_t bd_addr){ diff --git a/src/hfp_hf.h b/src/hfp_hf.h index da8febfe0..78a5a7714 100644 --- a/src/hfp_hf.h +++ b/src/hfp_hf.h @@ -154,6 +154,11 @@ void hfp_hf_release_audio_connection(bd_addr_t bd_addr); */ void hfp_hf_answer_incoming_call(bd_addr_t bd_addr); +/** + * @brief + */ +void hfp_hf_reject_call(bd_addr_t bd_addr); + /** * @brief */ diff --git a/test/pts/hfp_hf_test.c b/test/pts/hfp_hf_test.c index 228403b3a..081900ada 100644 --- a/test/pts/hfp_hf_test.c +++ b/test/pts/hfp_hf_test.c @@ -111,7 +111,9 @@ static void show_usage(void){ printf("f - answer incoming call\n"); printf("F - Hangup call\n"); + printf("G - Reject call.\n"); printf("g - query network operator name\n"); + printf("h - enable Calling Line Identification.\n"); printf("t - terminate connection\n"); @@ -171,6 +173,10 @@ static int stdin_process(struct data_source *ds){ printf("Hangup call.\n"); hfp_hf_terminate_call(device_addr); break; + case 'G': + printf("Reject call.\n"); + hfp_hf_reject_call(device_addr); + break; case 'g': printf("Query operator.\n"); hfp_hf_query_operator_selection(device_addr);