From 868fae3b10c22a6fdf89352bd5ac9d308f2dc80f Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Thu, 14 Jan 2016 12:12:35 +0100 Subject: [PATCH] hfp ag/gsm: update init methods --- src/hfp_ag.c | 44 +++++++++++++++++++++++++------------------- src/hfp_gsm_model.c | 11 ++++------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/hfp_ag.c b/src/hfp_ag.c index 668f8b782..78bd944b1 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -1391,11 +1391,11 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * connect case HFP_AG_OUTGOING_CALL_INITIATED: // directly reject call if number of free slots is exceeded - // if (!hfp_gsm_call_possible()){ - // connection->send_error = 1; - // hfp_run_for_context(connection); - // break; - // } + if (!hfp_gsm_call_possible()){ + connection->send_error = 1; + hfp_run_for_context(connection); + break; + } hfp_gsm_handle_event(HFP_AG_OUTGOING_CALL_INITIATED); connection->call_state = HFP_CALL_OUTGOING_INITIATED; @@ -1404,11 +1404,11 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * connect case HFP_AG_OUTGOING_REDIAL_INITIATED: // directly reject call if number of free slots is exceeded - // if (!hfp_gsm_call_possible()){ - // connection->send_error = 1; - // hfp_run_for_context(connection); - // break; - // } + if (!hfp_gsm_call_possible()){ + connection->send_error = 1; + hfp_run_for_context(connection); + break; + } hfp_gsm_handle_event(HFP_AG_OUTGOING_REDIAL_INITIATED); connection->call_state = HFP_CALL_OUTGOING_INITIATED; @@ -1498,16 +1498,16 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * connect break; } - // if ( (hfp_ag_callsetup_state != hfp_gsm_callsetup_status()) || - // (hfp_ag_callheld_state != hfp_gsm_callheld_status()) || - // (hfp_ag_call_state != hfp_gsm_call_status()) ){ + if ( (hfp_ag_callsetup_state != hfp_gsm_callsetup_status()) || + (hfp_ag_callheld_state != hfp_gsm_callheld_status()) || + (hfp_ag_call_state != hfp_gsm_call_status()) ){ - // printf("event %d\n", event); - // printf("callsetup %d - %d \n", hfp_ag_callsetup_state, hfp_gsm_callsetup_status()); - // printf("callheld %d - %d \n", hfp_ag_callheld_state, hfp_gsm_callheld_status()); - // printf("call %d - %d \n", hfp_ag_call_state, hfp_gsm_call_status()); - // exit(1); - // } + printf("event %d\n", event); + printf("callsetup %d - %d \n", hfp_ag_callsetup_state, hfp_gsm_callsetup_status()); + printf("callheld %d - %d \n", hfp_ag_callheld_state, hfp_gsm_callheld_status()); + printf("call %d - %d \n", hfp_ag_call_state, hfp_gsm_call_status()); + exit(1); + } } static void hfp_run_for_context(hfp_connection_t *context){ @@ -1950,6 +1950,12 @@ void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, hfp_ag_callsetup_state = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS; hfp_ag_callheld_state = HFP_CALLHELD_STATUS_NO_CALLS_HELD; + hfp_ag_response_and_hold_active = 0; + clip_type = 0; // 0 == not set + memset(clip_number,0,sizeof(clip_number)); + subscriber_numbers = NULL; + subscriber_numbers_count = 0; + hfp_gsm_init(); } diff --git a/src/hfp_gsm_model.c b/src/hfp_gsm_model.c index 6b85e3fb7..a0cb8e059 100644 --- a/src/hfp_gsm_model.c +++ b/src/hfp_gsm_model.c @@ -77,17 +77,14 @@ typedef struct { uint8_t clip_type; char clip_number[25]; } hfp_gsm_call_t; - - -// + static hfp_gsm_call_t gsm_calls[HFP_GSM_MAX_NR_CALLS]; +static hfp_callsetup_status_t callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS; void hfp_gsm_init(void){ memset(gsm_calls, 0, sizeof(gsm_calls)); -} -// -static hfp_callsetup_status_t callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS; - + callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS; +} static int get_number_calls_with_status(hfp_gsm_call_status_t status){ int i, count = 0;