From b29cac72b4721c08a59d525e85b3bf2b862faa65 Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Wed, 18 Nov 2015 16:34:26 +0100 Subject: [PATCH] hfp: remove one ok flag --- src/hfp.c | 5 ++--- src/hfp.h | 4 ++-- src/hfp_ag.c | 6 +++--- src/hfp_hf.c | 24 ++++++++++++------------ 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/hfp.c b/src/hfp.c index fca43858d..2fae653a7 100644 --- a/src/hfp.c +++ b/src/hfp.c @@ -257,8 +257,7 @@ hfp_connection_t * get_hfp_connection_context_for_sco_handle(uint16_t handle){ void hfp_reset_context_flags(hfp_connection_t * context){ if (!context) return; - context->wait_ok = 0; - context->send_ok = 0; + context->ok_pending = 0; context->send_error = 0; context->keep_separator = 0; @@ -942,7 +941,7 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){ break; case HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR: context->enable_extended_audio_gateway_error_report = (uint8_t)atoi((char*)context->line_buffer); - context->send_ok = 1; + context->ok_pending = 1; context->extended_audio_gateway_error = 0; break; default: diff --git a/src/hfp.h b/src/hfp.h index 4b257a6cc..6ed3f065f 100644 --- a/src/hfp.h +++ b/src/hfp.h @@ -377,8 +377,8 @@ typedef struct hfp_connection { uint8_t negotiated_codec; // TODO: put these bit flags in a bitmap - uint8_t wait_ok; - uint8_t send_ok; + uint8_t ok_pending; + // uint8_t send_ok; uint8_t send_error; uint8_t keep_separator; diff --git a/src/hfp_ag.c b/src/hfp_ag.c index 8e473f2b7..9abd1b90d 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -706,16 +706,16 @@ static void hfp_run_for_context(hfp_connection_t *context){ if (context->command == HFP_CMD_UNKNOWN){ hfp_ag_error(context->rfcomm_cid); - context->send_ok = 0; + context->ok_pending = 0; context->send_error = 0; context->command = HFP_CMD_NONE; return; } - if (context->send_ok){ + if (context->ok_pending){ hfp_ag_ok(context->rfcomm_cid); - context->send_ok = 0; + context->ok_pending = 0; context->command = HFP_CMD_NONE; return; } diff --git a/src/hfp_hf.c b/src/hfp_hf.c index 5b90c32c2..e2c962583 100644 --- a/src/hfp_hf.c +++ b/src/hfp_hf.c @@ -252,7 +252,7 @@ static void hfp_emit_network_operator_event(hfp_callback_t callback, int status, static int hfp_hf_run_for_context_service_level_connection(hfp_connection_t * context){ if (context->state >= HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) return 0; int done = 0; - if (context->wait_ok) return done; + if (context->ok_pending) return done; switch (context->state){ case HFP_EXCHANGE_SUPPORTED_FEATURES: @@ -375,12 +375,12 @@ static void hfp_hf_handle_ok_service_level_connection_establishment(hfp_connecti static int hfp_hf_run_for_context_service_level_connection_queries(hfp_connection_t * context){ if (context->state != HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) return 0; - if (context->wait_ok) return 0; + if (context->ok_pending) return 0; int done = 0; if (context->enable_status_update_for_ag_indicators != 0xFF){ hfp_hf_cmd_activate_status_update_for_all_ag_indicators(context->rfcomm_cid, context->enable_status_update_for_ag_indicators); - context->wait_ok = 1; + context->ok_pending = 1; done = 1; return done; }; @@ -388,27 +388,27 @@ static int hfp_hf_run_for_context_service_level_connection_queries(hfp_connectio hfp_hf_cmd_activate_status_update_for_ag_indicator(context->rfcomm_cid, context->ag_indicators_status_update_bitmap, context->ag_indicators_nr); - context->wait_ok = 1; + context->ok_pending = 1; done = 1; return done; } if (context->command == HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT){ hfp_hf_cmd_query_operator_name_format(context->rfcomm_cid); - context->wait_ok = 1; + context->ok_pending = 1; done = 1; return done; } if (context->command == HFP_CMD_QUERY_OPERATOR_SELECTION_NAME){ hfp_hf_cmd_query_operator_name(context->rfcomm_cid); - context->wait_ok = 1; + context->ok_pending = 1; done = 1; return done; } if (context->enable_extended_audio_gateway_error_report){ hfp_hf_cmd_enable_extended_audio_gateway_error_report(context->rfcomm_cid, context->enable_extended_audio_gateway_error_report); - context->wait_ok = 1; + context->ok_pending = 1; done = 1; return done; } @@ -447,7 +447,7 @@ static void hfp_hf_handle_ok_service_level_connection_queries(hfp_connection_t * } static int codecs_exchange_state_machine(hfp_connection_t * context){ - if (context->wait_ok) return 0; + if (context->ok_pending) return 0; int done = 0; switch(context->command){ @@ -495,7 +495,7 @@ static int codecs_exchange_state_machine(hfp_connection_t * context){ } if (done){ - context->wait_ok = 1; + context->ok_pending = 1; } return done; } @@ -538,7 +538,7 @@ static void hfp_run_for_context(hfp_connection_t * context){ static void hfp_hf_switch_on_ok(hfp_connection_t *context){ // printf("switch on ok\n"); - context->wait_ok = 0; + context->ok_pending = 0; hfp_hf_handle_ok_service_level_connection_establishment(context); hfp_hf_handle_ok_service_level_connection_queries(context); @@ -568,13 +568,13 @@ static void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8 } if (context->command == HFP_CMD_ERROR){ - context->wait_ok = 0; + context->ok_pending = 0; hfp_reset_context_flags(context); hfp_emit_event(hfp_callback, HFP_SUBEVENT_COMPLETE, 1); return; } if (context->command == HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR){ - context->wait_ok = 0; + context->ok_pending = 0; hfp_emit_event(hfp_callback, HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR, context->extended_audio_gateway_error); context->extended_audio_gateway_error = 0; return;