From 66ee7d3e0b8e2fdbad98ddd5b7f238d01a1dad53 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 27 Nov 2015 13:46:41 +0100 Subject: [PATCH] hfp: support CLIP in HF --- src/hfp.h | 28 ++++++++++++++-------------- src/hfp_hf.c | 21 +++++++++++++++++++++ src/hfp_hf.h | 5 +++++ test/pts/hfp_hf_test.c | 11 +++++++++++ 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/src/hfp.h b/src/hfp.h index 48fb8264a..fb76362a7 100644 --- a/src/hfp.h +++ b/src/hfp.h @@ -510,11 +510,7 @@ typedef struct hfp_connection { uint8_t establish_audio_connection; uint8_t release_audio_connection; - uint8_t change_in_band_ring_tone_setting; - uint8_t ag_ring; - uint8_t ag_send_clip; - uint8_t ag_echo_and_noise_reduction; - uint8_t ag_activate_voice_recognition; + timer_source_t hfp_timeout; uint8_t microphone_gain; uint8_t send_microphone_gain; @@ -523,22 +519,26 @@ typedef struct hfp_connection { uint8_t send_speaker_gain; uint8_t send_phone_number_for_voice_tag; - + uint8_t send_ag_status_indicators; + uint8_t send_response_and_hold_active; + uint8_t send_response_and_hold_status; + + // AG only + uint8_t change_in_band_ring_tone_setting; + uint8_t ag_ring; + uint8_t ag_send_clip; + uint8_t ag_echo_and_noise_reduction; + uint8_t ag_activate_voice_recognition; uint8_t send_subscriber_number; - int next_subscriber_number_to_send; + uint8_t next_subscriber_number_to_send; int send_status_of_current_calls; - - uint8_t hf_answer_incoming_call; - - int send_ag_status_indicators; - int send_response_and_hold_active; - int send_response_and_hold_status; // HF only hfp_hf_query_operator_state_t hf_query_operator_state; + uint8_t hf_answer_incoming_call; + uint8_t hf_send_clip_enable; - timer_source_t hfp_timeout; } hfp_connection_t; // UTILS_START : TODO move to utils diff --git a/src/hfp_hf.c b/src/hfp_hf.c index af986cedc..412abfcfe 100644 --- a/src/hfp_hf.c +++ b/src/hfp_hf.c @@ -236,6 +236,12 @@ static int hfp_hf_cmd_ata(uint16_t cid){ return send_str_over_rfcomm(cid, buffer); } +static int hfp_hf_send_clip_enable(uint16_t cid){ + char buffer[20]; + sprintf(buffer, "AT%s=1\r\n", HFP_ENABLE_CLIP); + return send_str_over_rfcomm(cid, buffer); +} + static void hfp_emit_ag_indicator_event(hfp_callback_t callback, int status, hfp_ag_indicator_t indicator){ if (!callback) return; uint8_t event[6+HFP_MAX_INDICATOR_DESC_SIZE+1]; @@ -333,6 +339,13 @@ static int hfp_hf_run_for_context_service_level_connection_queries(hfp_connectio return done; } + if (context->hf_send_clip_enable){ + context->hf_send_clip_enable = 0; + context->ok_pending = 1; + hfp_hf_send_clip_enable(context->rfcomm_cid); + return 1; + } + switch (context->hf_query_operator_state){ case HFP_HF_QUERY_OPERATOR_SET_FORMAT: context->hf_query_operator_state = HFP_HF_QUERY_OPERATOR_W4_SET_FORMAT_OK; @@ -813,9 +826,17 @@ void hfp_hf_answer_incoming_call(bd_addr_t bd_addr){ // HACK - remove after hfp_callsetup_state is updated connection->hf_answer_incoming_call = 1; (void) hfp_callsetup_state; + hfp_run_for_context(connection); // if (hfp_callsetup_state == HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS){ // connection->hf_answer_incoming_call = 1; // } else { // log_error("HFP HF: answering incoming call in wrong callsetup state %u", hfp_callsetup_state); // } } + +void hfp_hf_enable_calling_line_identification(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_clip_enable = 1; + hfp_run_for_context(connection); +} diff --git a/src/hfp_hf.h b/src/hfp_hf.h index 4e2100431..49f0d070c 100644 --- a/src/hfp_hf.h +++ b/src/hfp_hf.h @@ -155,6 +155,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_enable_calling_line_identification(bd_addr_t bd_addr); + /* API_END */ #if defined __cplusplus diff --git a/test/pts/hfp_hf_test.c b/test/pts/hfp_hf_test.c index 52c658371..3fbd262b9 100644 --- a/test/pts/hfp_hf_test.c +++ b/test/pts/hfp_hf_test.c @@ -111,6 +111,7 @@ static void show_usage(void){ printf("f - answer incoming call\n"); printf("g - query network operator name\n"); + printf("h - enable Calling Line Identification.\n"); printf("t - terminate connection\n"); @@ -169,6 +170,10 @@ static int stdin_process(struct data_source *ds){ printf("Query operator.\n"); hfp_hf_query_operator_selection(device_addr); break; + case 'h': + printf("Enable Calling Line Identification.\n"); + hfp_hf_enable_calling_line_identification(device_addr); + break; case 't': printf("Terminate HCI connection.\n"); gap_disconnect(handle); @@ -204,6 +209,12 @@ static void packet_handler(uint8_t * event, uint16_t event_size){ case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED: printf("Service level connection released.\n\n"); break; + case HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED: + printf("\n** Audio connection established **\n"); + break; + case HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED: + printf("\n** Audio connection released **\n"); + break; case HFP_SUBEVENT_COMPLETE: switch (cmd){ case 'd':