hfp: remove one ok flag

This commit is contained in:
Milanka Ringwald 2015-11-18 16:34:26 +01:00
parent 53d4b99082
commit b29cac72b4
4 changed files with 19 additions and 20 deletions

View File

@ -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){ void hfp_reset_context_flags(hfp_connection_t * context){
if (!context) return; if (!context) return;
context->wait_ok = 0; context->ok_pending = 0;
context->send_ok = 0;
context->send_error = 0; context->send_error = 0;
context->keep_separator = 0; context->keep_separator = 0;
@ -942,7 +941,7 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
break; break;
case HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR: case HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR:
context->enable_extended_audio_gateway_error_report = (uint8_t)atoi((char*)context->line_buffer); 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; context->extended_audio_gateway_error = 0;
break; break;
default: default:

View File

@ -377,8 +377,8 @@ typedef struct hfp_connection {
uint8_t negotiated_codec; uint8_t negotiated_codec;
// TODO: put these bit flags in a bitmap // TODO: put these bit flags in a bitmap
uint8_t wait_ok; uint8_t ok_pending;
uint8_t send_ok; // uint8_t send_ok;
uint8_t send_error; uint8_t send_error;
uint8_t keep_separator; uint8_t keep_separator;

View File

@ -706,16 +706,16 @@ static void hfp_run_for_context(hfp_connection_t *context){
if (context->command == HFP_CMD_UNKNOWN){ if (context->command == HFP_CMD_UNKNOWN){
hfp_ag_error(context->rfcomm_cid); hfp_ag_error(context->rfcomm_cid);
context->send_ok = 0; context->ok_pending = 0;
context->send_error = 0; context->send_error = 0;
context->command = HFP_CMD_NONE; context->command = HFP_CMD_NONE;
return; return;
} }
if (context->send_ok){ if (context->ok_pending){
hfp_ag_ok(context->rfcomm_cid); hfp_ag_ok(context->rfcomm_cid);
context->send_ok = 0; context->ok_pending = 0;
context->command = HFP_CMD_NONE; context->command = HFP_CMD_NONE;
return; return;
} }

View File

@ -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){ static int hfp_hf_run_for_context_service_level_connection(hfp_connection_t * context){
if (context->state >= HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) return 0; if (context->state >= HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) return 0;
int done = 0; int done = 0;
if (context->wait_ok) return done; if (context->ok_pending) return done;
switch (context->state){ switch (context->state){
case HFP_EXCHANGE_SUPPORTED_FEATURES: 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){ 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->state != HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) return 0;
if (context->wait_ok) return 0; if (context->ok_pending) return 0;
int done = 0; int done = 0;
if (context->enable_status_update_for_ag_indicators != 0xFF){ 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); 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; done = 1;
return done; 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, hfp_hf_cmd_activate_status_update_for_ag_indicator(context->rfcomm_cid,
context->ag_indicators_status_update_bitmap, context->ag_indicators_status_update_bitmap,
context->ag_indicators_nr); context->ag_indicators_nr);
context->wait_ok = 1; context->ok_pending = 1;
done = 1; done = 1;
return done; return done;
} }
if (context->command == HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT){ if (context->command == HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT){
hfp_hf_cmd_query_operator_name_format(context->rfcomm_cid); hfp_hf_cmd_query_operator_name_format(context->rfcomm_cid);
context->wait_ok = 1; context->ok_pending = 1;
done = 1; done = 1;
return done; return done;
} }
if (context->command == HFP_CMD_QUERY_OPERATOR_SELECTION_NAME){ if (context->command == HFP_CMD_QUERY_OPERATOR_SELECTION_NAME){
hfp_hf_cmd_query_operator_name(context->rfcomm_cid); hfp_hf_cmd_query_operator_name(context->rfcomm_cid);
context->wait_ok = 1; context->ok_pending = 1;
done = 1; done = 1;
return done; return done;
} }
if (context->enable_extended_audio_gateway_error_report){ 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); 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; done = 1;
return done; 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){ 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; int done = 0;
switch(context->command){ switch(context->command){
@ -495,7 +495,7 @@ static int codecs_exchange_state_machine(hfp_connection_t * context){
} }
if (done){ if (done){
context->wait_ok = 1; context->ok_pending = 1;
} }
return done; 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){ static void hfp_hf_switch_on_ok(hfp_connection_t *context){
// printf("switch on ok\n"); // 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_establishment(context);
hfp_hf_handle_ok_service_level_connection_queries(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){ if (context->command == HFP_CMD_ERROR){
context->wait_ok = 0; context->ok_pending = 0;
hfp_reset_context_flags(context); hfp_reset_context_flags(context);
hfp_emit_event(hfp_callback, HFP_SUBEVENT_COMPLETE, 1); hfp_emit_event(hfp_callback, HFP_SUBEVENT_COMPLETE, 1);
return; return;
} }
if (context->command == HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR){ 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); hfp_emit_event(hfp_callback, HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR, context->extended_audio_gateway_error);
context->extended_audio_gateway_error = 0; context->extended_audio_gateway_error = 0;
return; return;