From 4bc5b29fb07c080fb4fd49708171413fdf23c0d7 Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Fri, 28 Aug 2015 09:47:40 +0200 Subject: [PATCH] hfp: fixed hfp test --- src/hfp.c | 2 +- src/hfp_hf.c | 16 +++++++++++++--- test/hfp/hfp_hf_client_test.c | 12 ++++++------ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/hfp.c b/src/hfp.c index abc9a27ac..203cc16d6 100644 --- a/src/hfp.c +++ b/src/hfp.c @@ -702,7 +702,7 @@ void process_command(hfp_connection_t * context){ } if (strncmp((char *)context->line_buffer+offset, HFP_CONFIRM_COMMON_CODEC, strlen(HFP_CONFIRM_COMMON_CODEC)) == 0){ - if (isHandsFree){ + if (!isHandsFree){ context->command = HFP_CMD_HF_CONFIRMED_CODEC; } else { context->command = HFP_CMD_AG_SUGGESTED_CODEC; diff --git a/src/hfp_hf.c b/src/hfp_hf.c index 694fe3ec7..a88475efd 100644 --- a/src/hfp_hf.c +++ b/src/hfp_hf.c @@ -491,9 +491,19 @@ static void hfp_run_for_context(hfp_connection_t * context){ break; } if (context->suggested_codec){ - context->codec_confirmed = 1; - context->wait_ok = 1; - hfp_hf_cmd_confirm_codec(context->rfcomm_cid, context->suggested_codec); + if (hfp_hf_supports_codec(context->suggested_codec)){ + context->codec_confirmed = context->suggested_codec; + context->wait_ok = 1; + hfp_hf_cmd_confirm_codec(context->rfcomm_cid, context->suggested_codec); + } else { + context->notify_ag_on_new_codecs = 1; + context->wait_ok = 1; + context->codec_confirmed = 0; + context->suggested_codec = 0; + context->negotiated_codec = 0; + hfp_hf_cmd_notify_on_codecs(context->rfcomm_cid); + } + break; } diff --git a/test/hfp/hfp_hf_client_test.c b/test/hfp/hfp_hf_client_test.c index 2f9ae304f..904190eec 100644 --- a/test/hfp/hfp_hf_client_test.c +++ b/test/hfp/hfp_hf_client_test.c @@ -283,12 +283,12 @@ TEST_GROUP(HandsfreeClient){ }; -// TEST(HandsfreeClient, HFCodecsConnectionEstablished){ -// setup_hfp_service_level_connection(default_slc_setup, default_slc_setup_size); -// for (int i = 0; i < cc_tests_size; i++){ -// setup_hfp_codecs_connection_state_machine(hfp_cc_tests[i].test, hfp_cc_tests[i].len); -// } -// } +TEST(HandsfreeClient, HFCodecsConnectionEstablished){ + setup_hfp_service_level_connection(default_slc_setup, default_slc_setup_size); + for (int i = 0; i < cc_tests_size; i++){ + setup_hfp_codecs_connection_state_machine(hfp_cc_tests[i].test, hfp_cc_tests[i].len); + } +} TEST(HandsfreeClient, HFCodecChange){ setup_hfp_service_level_connection(default_slc_setup, default_slc_setup_size);