hfp: extract codecs connection SM

This commit is contained in:
Milanka Ringwald 2015-08-28 10:05:59 +02:00
parent 792c3260ea
commit 903f1eca9f

View File

@ -249,9 +249,8 @@ static void hfp_emit_network_operator_event(hfp_callback_t callback, int status,
(*callback)(event, sizeof(event));
}
static void hfp_hf_run_for_context_service_level_connection_establishment(hfp_connection_t * context){
static void hfp_hf_run_for_context_service_level_connection(hfp_connection_t * context){
if (context->state >= HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) return;
printf("hfp_hf_run_for_context_service_level_connection_establishment %d \n", context->state);
switch (context->state){
case HFP_EXCHANGE_SUPPORTED_FEATURES:
hfp_hf_cmd_exchange_supported_features(context->rfcomm_cid);
@ -441,15 +440,8 @@ static void hfp_hf_handle_ok_service_level_connection_queries(hfp_connection_t *
}
}
//
static void hfp_run_for_context(hfp_connection_t * context){
if (!context) return;
if (!rfcomm_can_send_packet_now(context->rfcomm_cid)) return;
hfp_hf_run_for_context_service_level_connection_establishment(context);
hfp_hf_run_for_context_service_level_connection_queries(context);
static void hfp_hf_run_for_context_codecs_connection(hfp_connection_t * context){
// if (context->state >= HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED && context->state <= HFP_AUDIO_CONNECTION_ESTABLISHED){
// handle audio connection setup
@ -531,28 +523,10 @@ static void hfp_run_for_context(hfp_connection_t * context){
default:
break;
}
// deal with disconnect
switch (context->state){
case HFP_W2_DISCONNECT_RFCOMM:
context->state = HFP_W4_RFCOMM_DISCONNECTED;
rfcomm_disconnect_internal(context->rfcomm_cid);
break;
default:
break;
}
}
void hfp_hf_switch_on_ok(hfp_connection_t *context){
// printf("switch on ok\n");
context->wait_ok = 0;
hfp_hf_handle_ok_service_level_connection_establishment(context);
hfp_hf_handle_ok_service_level_connection_queries(context);
// handle audio connection setup
static void hfp_hf_handle_ok_codecs_connection(hfp_connection_t * context){
// handle audio connection setup
switch (context->state){
case HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED:
if (context->notify_ag_on_new_codecs){
@ -589,8 +563,38 @@ void hfp_hf_switch_on_ok(hfp_connection_t *context){
default:
break;
}
}
static void hfp_run_for_context(hfp_connection_t * context){
if (!context) return;
if (!rfcomm_can_send_packet_now(context->rfcomm_cid)) return;
hfp_hf_run_for_context_service_level_connection(context);
hfp_hf_run_for_context_service_level_connection_queries(context);
hfp_hf_run_for_context_codecs_connection(context);
// deal with disconnect
switch (context->state){
case HFP_W2_DISCONNECT_RFCOMM:
context->state = HFP_W4_RFCOMM_DISCONNECTED;
rfcomm_disconnect_internal(context->rfcomm_cid);
break;
default:
break;
}
}
void hfp_hf_switch_on_ok(hfp_connection_t *context){
// printf("switch on ok\n");
context->wait_ok = 0;
hfp_hf_handle_ok_service_level_connection_establishment(context);
hfp_hf_handle_ok_service_level_connection_queries(context);
hfp_hf_handle_ok_codecs_connection(context);
// done
context->command = HFP_CMD_NONE;
}