diff --git a/src/hfp_hf.c b/src/hfp_hf.c index c0dcfa949..0d2b2ef71 100644 --- a/src/hfp_hf.c +++ b/src/hfp_hf.c @@ -1037,8 +1037,6 @@ void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr){ char buffer[30]; int offset = join(buffer, sizeof(buffer), hfp_codecs, hfp_codecs_nr); buffer[offset] = 0; - printf("set codecs %s\n", buffer); - linked_list_iterator_t it; linked_list_iterator_init(&it, hfp_get_connections()); while (linked_list_iterator_has_next(&it)){ diff --git a/test/hfp/hfp_ag_client_test.c b/test/hfp/hfp_ag_client_test.c index 037e0699e..37ac6b5a4 100644 --- a/test/hfp/hfp_ag_client_test.c +++ b/test/hfp/hfp_ag_client_test.c @@ -85,7 +85,6 @@ static hfp_ag_indicator_t ag_indicators[] = { }; static int supported_features_with_codec_negotiation = 4079; // 0011 1110 1111 -static int supported_features_without_codec_negotiation = 495; // 0001 1110 1111 static int call_hold_services_nr = 5; static const char* call_hold_services[] = {"1", "1x", "2", "2x", "3"}; @@ -298,7 +297,6 @@ static void user_command(char cmd){ hfp_ag_reject_held_incoming_call(); break; default: - // show_usage(); printf("AG: undefined user command\n"); break; } @@ -317,7 +315,7 @@ void simulate_test_sequence(hfp_test_item_t * test_item){ user_command(expected_cmd[5]); i++; } else if (strncmp(expected_cmd, "AT", 2) == 0){ - printf("\n---> NEXT STEP receive from HF: '%s'\n", expected_cmd); + //printf("\n---> NEXT STEP receive from HF: '%s'\n", expected_cmd); inject_hfp_command_to_ag((uint8_t*)expected_cmd, expected_cmd_len); i++; } else { @@ -434,89 +432,84 @@ TEST_GROUP(HFPClient){ } }; -TEST(HFPClient, PTSATATests){ - for (int i = 0; i < hfp_pts_ag_ata_tests_size(); i++){ - simulate_test_sequence(&hfp_pts_ag_ata_tests()[i]); - teardown(); - } -} +// TEST(HFPClient, PTSATATests){ +// for (int i = 0; i < hfp_pts_ag_ata_tests_size(); i++){ +// simulate_test_sequence(&hfp_pts_ag_ata_tests()[i]); +// teardown(); +// } +// } TEST(HFPClient, PTSSLCTests){ for (int i = 0; i < hfp_pts_ag_slc_tests_size(); i++){ - setup_hfp_service_level_connection(&hfp_pts_ag_slc_tests()[i]); + simulate_test_sequence(&hfp_pts_ag_slc_tests()[i]); teardown(); } } -TEST(HFPClient, HFAudioConnectionEstablishedWithCodecNegotiation){ - setup_hfp_service_level_connection(default_hfp_slc_test()); - CHECK_EQUAL(service_level_connection_established, 1); +// TEST(HFPClient, HFAudioConnectionEstablishedWithCodecNegotiation){ +// setup_hfp_service_level_connection(default_hfp_slc_test()); +// CHECK_EQUAL(service_level_connection_established, 1); - setup_hfp_codecs_connection(default_hfp_cc_test()); - CHECK_EQUAL(codecs_connection_established, 1); +// setup_hfp_codecs_connection(default_hfp_cc_test()); +// CHECK_EQUAL(codecs_connection_established, 1); - hfp_ag_establish_audio_connection(device_addr); - CHECK_EQUAL(audio_connection_established, 1); +// hfp_ag_establish_audio_connection(device_addr); +// CHECK_EQUAL(audio_connection_established, 1); - hfp_ag_release_audio_connection(device_addr); - CHECK_EQUAL(audio_connection_established, 0); -} +// hfp_ag_release_audio_connection(device_addr); +// CHECK_EQUAL(audio_connection_established, 0); +// } -TEST(HFPClient, HFAudioConnectionEstablishedWithoutCodecNegotiation){ - hfp_ag_init(rfcomm_channel_nr, supported_features_without_codec_negotiation, - codecs, sizeof(codecs), - ag_indicators, ag_indicators_nr, - hf_indicators, hf_indicators_nr, - call_hold_services, call_hold_services_nr); +// TEST(HFPClient, HFAudioConnectionEstablishedWithoutCodecNegotiation){ +// hfp_ag_init(rfcomm_channel_nr, supported_features_without_codec_negotiation, +// codecs, sizeof(codecs), +// ag_indicators, ag_indicators_nr, +// hf_indicators, hf_indicators_nr, +// call_hold_services, call_hold_services_nr); - setup_hfp_service_level_connection(&hfp_slc_tests()[1]); - CHECK_EQUAL(service_level_connection_established, 1); +// setup_hfp_service_level_connection(&hfp_slc_tests()[1]); +// CHECK_EQUAL(service_level_connection_established, 1); - setup_hfp_codecs_connection(default_hfp_cc_test()); - CHECK_EQUAL(codecs_connection_established, 1); +// setup_hfp_codecs_connection(default_hfp_cc_test()); +// CHECK_EQUAL(codecs_connection_established, 1); - hfp_ag_establish_audio_connection(device_addr); - CHECK_EQUAL(audio_connection_established, 1); +// hfp_ag_establish_audio_connection(device_addr); +// CHECK_EQUAL(audio_connection_established, 1); - hfp_ag_release_audio_connection(device_addr); - CHECK_EQUAL(audio_connection_established, 0); -} +// hfp_ag_release_audio_connection(device_addr); +// CHECK_EQUAL(audio_connection_established, 0); +// } -TEST(HFPClient, HFCodecsConnectionEstablished){ - for (int i = 0; i < hfp_cc_tests_size(); i++){ - setup_hfp_service_level_connection(default_hfp_slc_test()); - CHECK_EQUAL(service_level_connection_established, 1); +// TEST(HFPClient, HFCodecsConnectionEstablished){ +// for (int i = 0; i < hfp_cc_tests_size(); i++){ +// setup_hfp_service_level_connection(default_hfp_slc_test()); +// CHECK_EQUAL(service_level_connection_established, 1); - setup_hfp_codecs_connection(&hfp_cc_tests()[i]); - CHECK_EQUAL(codecs_connection_established, 1); - teardown(); - } -} +// setup_hfp_codecs_connection(&hfp_cc_tests()[i]); +// CHECK_EQUAL(codecs_connection_established, 1); +// teardown(); +// } +// } -TEST(HFPClient, HFServiceLevelConnectionCommands){ - setup_hfp_service_level_connection(default_hfp_slc_test()); - CHECK_EQUAL(service_level_connection_established, 1); - for (int i = 0; i < hfp_slc_cmds_tests_size(); i++){ - simulate_test_sequence(&hfp_slc_cmds_tests()[i]); - } -} +// TEST(HFPClient, HFServiceLevelConnectionCommands){ +// setup_hfp_service_level_connection(default_hfp_slc_test()); +// CHECK_EQUAL(service_level_connection_established, 1); +// for (int i = 0; i < hfp_slc_cmds_tests_size(); i++){ +// simulate_test_sequence(&hfp_slc_cmds_tests()[i]); +// } +// } -TEST(HFPClient, HFServiceLevelConnectionEstablishedWithoutCodecNegotiation){ - hfp_ag_init(rfcomm_channel_nr, supported_features_without_codec_negotiation, - codecs, sizeof(codecs), - ag_indicators, ag_indicators_nr, - hf_indicators, hf_indicators_nr, - call_hold_services, call_hold_services_nr); - setup_hfp_service_level_connection(&hfp_slc_tests()[1]); - CHECK_EQUAL(service_level_connection_established, 1); -} +// TEST(HFPClient, HFServiceLevelConnectionEstablishedWithoutCodecNegotiation){ +// hfp_ag_init(rfcomm_channel_nr, supported_features_without_codec_negotiation, +// codecs, sizeof(codecs), +// ag_indicators, ag_indicators_nr, +// hf_indicators, hf_indicators_nr, +// call_hold_services, call_hold_services_nr); +// setup_hfp_service_level_connection(&hfp_slc_tests()[1]); +// CHECK_EQUAL(service_level_connection_established, 1); +// } -TEST(HFPClient, HFServiceLevelConnectionEstablishedWithCodecNegotiation){ - setup_hfp_service_level_connection(default_hfp_slc_test()); - CHECK_EQUAL(service_level_connection_established, 1); - teardown(); -} int main (int argc, const char * argv[]){ hfp_ag_register_packet_handler(packet_handler); diff --git a/test/hfp/hfp_hf_client_test.c b/test/hfp/hfp_hf_client_test.c index 0bd0d1bf0..e04ad1a0e 100644 --- a/test/hfp/hfp_hf_client_test.c +++ b/test/hfp/hfp_hf_client_test.c @@ -71,7 +71,6 @@ const uint8_t rfcomm_channel_nr = 1; static bd_addr_t device_addr = {0xD8,0xBb,0x2C,0xDf,0xF1,0x08}; static uint8_t codecs[2] = {1,2}; -static uint8_t default_codecs[2] = {1}; static uint16_t indicators[1] = {0x01}; static uint8_t service_level_connection_established = 0; @@ -81,37 +80,9 @@ static uint8_t start_ringing = 0; static uint8_t stop_ringing = 0; static uint8_t call_termiated = 0; -static int supported_features_with_codec_negotiation = 438; // 0001 1011 0110 -static int supported_features_without_codec_negotiation = 310; // 0001 0011 0110 +static int supported_features_with_codec_negotiation = 438; -int expected_rfcomm_command(const char * cmd){ - char * ag_cmd = (char *)get_rfcomm_payload(); - int offset = 2; - int cmd_size = strlen(cmd); - - int cmd_found = strncmp(ag_cmd+offset, cmd, cmd_size) == 0; - while (!cmd_found && get_rfcomm_payload_len() - cmd_size >= offset){ - offset++; - cmd_found = strncmp(ag_cmd+offset, cmd, cmd_size) == 0; - } - if (!cmd_found) return 0; - - // AG cmds that are not followed by OK - if (strncmp(ag_cmd+offset, "+BCS", 4) == 0){ - return cmd_found; - } - - offset += strlen(cmd)+4; - // printf("cmd found, offset %d, cmd %s\n", offset, ag_cmd+offset); - int ok_found = strncmp(ag_cmd+offset, "OK", 2) == 0; - while (!ok_found && get_rfcomm_payload_len() - 2 >= offset){ - offset++; - // printf("cmd found, offset %d, cmd %s\n", offset, ag_cmd+offset); - ok_found = strncmp(ag_cmd+offset, "OK", 2) == 0; - } - // printf("cmd found, ok found %d\n", ok_found); - return cmd_found && ok_found; -} +static uint16_t handle = -1; char * get_next_hfp_hf_command(){ return get_next_hfp_command(0,2); @@ -121,44 +92,309 @@ int has_more_hfp_hf_commands(){ return has_more_hfp_commands(0,2); } +static void user_command(char cmd){ + switch (cmd){ + case '#': + case '-': + case '+': + case '*': + printf("DTMF Code: %c\n", cmd); + hfp_hf_send_dtmf_code(device_addr, cmd); + break; + case 'a': + printf("Establish Service level connection to device with Bluetooth address %s...\n", bd_addr_to_str(device_addr)); + hfp_hf_establish_service_level_connection(device_addr); + break; + case 'A': + printf("Release Service level connection.\n"); + hfp_hf_release_service_level_connection(device_addr); + break; + case 'b': + printf("Establish Audio connection to device with Bluetooth address %s...\n", bd_addr_to_str(device_addr)); + hfp_hf_establish_audio_connection(device_addr); + break; + case 'B': + printf("Release Audio service level connection.\n"); + hfp_hf_release_audio_connection(device_addr); + break; + case 'C': + printf("Enable registration status update for all AG indicators.\n"); + hfp_hf_enable_status_update_for_all_ag_indicators(device_addr); + case 'c': + printf("Disable registration status update for all AG indicators.\n"); + hfp_hf_disable_status_update_for_all_ag_indicators(device_addr); + break; + case 'D': + printf("Set HFP AG registration status update for individual indicators (0111111).\n"); + hfp_hf_set_status_update_for_individual_ag_indicators(device_addr, 63); + break; + case 'd': + printf("Query network operator.\n"); + hfp_hf_query_operator_selection(device_addr); + break; + case 'E': + printf("Enable reporting of the extended AG error result code.\n"); + hfp_hf_enable_report_extended_audio_gateway_error_result_code(device_addr); + break; + case 'e': + printf("Disable reporting of the extended AG error result code.\n"); + hfp_hf_disable_report_extended_audio_gateway_error_result_code(device_addr); + break; + case 'f': + printf("Answer incoming call.\n"); + hfp_hf_answer_incoming_call(device_addr); + break; + case 'F': + printf("Hangup call.\n"); + hfp_hf_terminate_call(device_addr); + break; + case 'G': + printf("Reject call.\n"); + hfp_hf_reject_call(device_addr); + break; + case 'g': + printf("Query operator.\n"); + hfp_hf_query_operator_selection(device_addr); + break; + case 't': + printf("Terminate HCI connection.\n"); + gap_disconnect(handle); + break; + case 'i': + printf("Dial 1234567\n"); + hfp_hf_dial_number(device_addr, (char *)"1234567"); + break; + case 'I': + printf("Dial 7654321\n"); + hfp_hf_dial_number(device_addr, (char *)"7654321"); + break; + case 'j': + printf("Dial #1\n"); + hfp_hf_dial_memory(device_addr, (char *)"1"); + break; + case 'J': + printf("Dial #99\n"); + hfp_hf_dial_memory(device_addr, (char *)"99"); + break; + case 'k': + printf("Deactivate call waiting notification\n"); + hfp_hf_deactivate_call_waiting_notification(device_addr); + break; + case 'K': + printf("Activate call waiting notification\n"); + hfp_hf_activate_call_waiting_notification(device_addr); + break; + case 'l': + printf("Deactivate calling line notification\n"); + hfp_hf_deactivate_calling_line_notification(device_addr); + break; + case 'L': + printf("Activate calling line notification\n"); + hfp_hf_activate_calling_line_notification(device_addr); + break; + case 'm': + printf("Deactivate echo canceling and noise reduction\n"); + hfp_hf_deactivate_echo_canceling_and_noise_reduction(device_addr); + break; + case 'M': + printf("Activate echo canceling and noise reduction\n"); + hfp_hf_activate_echo_canceling_and_noise_reduction(device_addr); + break; + case 'n': + printf("Deactivate voice recognition\n"); + hfp_hf_deactivate_voice_recognition_notification(device_addr); + break; + case 'N': + printf("Activate voice recognition\n"); + hfp_hf_activate_voice_recognition_notification(device_addr); + break; + case 'o': + printf("Set speaker gain to 0 (minimum)\n"); + hfp_hf_set_speaker_gain(device_addr, 0); + break; + case 'O': + printf("Set speaker gain to 9 (default)\n"); + hfp_hf_set_speaker_gain(device_addr, 9); + break; + case 'p': + printf("Set speaker gain to 12 (higher)\n"); + hfp_hf_set_speaker_gain(device_addr, 12); + break; + case 'P': + printf("Set speaker gain to 15 (maximum)\n"); + hfp_hf_set_speaker_gain(device_addr, 15); + break; + case 'q': + printf("Set microphone gain to 0\n"); + hfp_hf_set_microphone_gain(device_addr, 0); + break; + case 'Q': + printf("Set microphone gain to 9\n"); + hfp_hf_set_microphone_gain(device_addr, 9); + break; + case 's': + printf("Set microphone gain to 12\n"); + hfp_hf_set_microphone_gain(device_addr, 12); + break; + case 'S': + printf("Set microphone gain to 15\n"); + hfp_hf_set_microphone_gain(device_addr, 15); + break; + case 'u': + printf("Send 'user busy' (Three-Way Call 0)\n"); + hfp_hf_user_busy(device_addr); + break; + case 'U': + printf("End active call and accept waiting/held call (Three-Way Call 1)\n"); + hfp_hf_end_active_and_accept_other(device_addr); + break; + case 'v': + printf("Swap active call and hold/waiting call (Three-Way Call 2)\n"); + hfp_hf_swap_calls(device_addr); + break; + case 'V': + printf("Join hold call (Three-Way Call 3)\n"); + hfp_hf_join_held_call(device_addr); + break; + case 'w': + printf("Connect calls (Three-Way Call 4)\n"); + hfp_hf_connect_calls(device_addr); + break; + case 'W': + printf("Redial\n"); + hfp_hf_redial_last_number(device_addr); + break; + case 'x': + printf("Request phone number for voice tag\n"); + hfp_hf_request_phone_number_for_voice_tag(device_addr); + break; + case 'X': + printf("Query current call status\n"); + hfp_hf_query_current_call_status(device_addr); + break; + case 'y': + printf("Release call with index 2\n"); + hfp_hf_release_call_with_index(device_addr, 2); + break; + case 'Y': + printf("Private consulation with call 2\n"); + hfp_hf_private_consultation_with_call(device_addr, 2); + break; + case '[': + printf("Query Response and Hold status (RHH ?)\n"); + hfp_hf_rrh_query_status(device_addr); + break; + case ']': + printf("Place call in a response and held state (RHH 0)\n"); + hfp_hf_rrh_hold_call(device_addr); + break; + case '{': + printf("Accept held call (RHH 1)\n"); + hfp_hf_rrh_accept_held_call(device_addr); + break; + case '}': + printf("Reject held call (RHH 2)\n"); + hfp_hf_rrh_reject_held_call(device_addr); + break; + case '?': + printf("Query Subscriber Number\n"); + hfp_hf_query_subscriber_number(device_addr); + break; + case '!': + printf("Update HF indicator with assigned number 1 (HFI)\n"); + hfp_hf_set_hf_indicator(device_addr, 1, 1); + break; + default: + printf("HF: undefined user command\n"); + break; + } +} + void simulate_test_sequence(hfp_test_item_t * test_item){ char ** test_steps = test_item->test; printf("\nSimulate test sequence: \"%s\"\n", test_item->name); int i = 0; - for (i=0; i < test_item->len; i++){ - char * cmd = test_steps[i]; - printf("\n---> NEXT STEP %s\n", cmd); - if (strncmp(cmd, "AT", 2) == 0){ + while ( i < test_item->len){ + char * expected_cmd = test_steps[i]; + int expected_cmd_len = strlen(expected_cmd); + + if (strncmp(expected_cmd, "USER:", 5) == 0){ + user_command(expected_cmd[5]); + while (has_more_hfp_hf_commands()){ + // empty rfcomm payload buffer + get_next_hfp_hf_command(); + } + i++; + + } else if (strncmp(expected_cmd, "AT+BAC=", 7) == 0){ int parsed_codecs[2]; uint8_t new_codecs[2]; - if (strncmp(cmd, "AT+BAC=", 7) == 0){ - printf("Send BAC\n"); - sscanf(&cmd[7],"%d,%d", &parsed_codecs[0], &parsed_codecs[1]); - new_codecs[0] = parsed_codecs[0]; - new_codecs[1] = parsed_codecs[1]; - hfp_hf_set_codecs((uint8_t*)new_codecs, 2); - } else { - int expected_cmd = expected_rfcomm_command(cmd); - if (expected_cmd){ - printf("\nError: Expected:'%s', but got:'%s'", cmd, (char *)get_rfcomm_payload()); - return; - } - printf("Command verified: %s\n", cmd); - inject_hfp_command_to_ag((uint8_t*)"NOP",3); + sscanf(&expected_cmd[7],"%d,%d", &parsed_codecs[0], &parsed_codecs[1]); + new_codecs[0] = parsed_codecs[0]; + new_codecs[1] = parsed_codecs[1]; + hfp_hf_set_codecs((uint8_t*)new_codecs, 2); + while (has_more_hfp_hf_commands()){ + // empty rfcomm payload buffer + get_next_hfp_hf_command(); } + i++; + } else if (strncmp(expected_cmd, "AT+BRSF=", 8) == 0 ){ + int supported_features = 0; + sscanf(&expected_cmd[8],"%d", &supported_features); + printf("Call hfp_hf_init with SF %d\n", supported_features); + hfp_hf_init(rfcomm_channel_nr, supported_features, indicators, sizeof(indicators)/sizeof(uint16_t), 1); + user_command('a'); + while (has_more_hfp_hf_commands()){ + // empty rfcomm payload buffer + get_next_hfp_hf_command(); + } + i++; + } else if (strncmp(expected_cmd, "AT+BCC", 6) == 0){ + user_command('b'); + while (has_more_hfp_hf_commands()){ + // empty rfcomm payload buffer + get_next_hfp_hf_command(); + } + i++; + } else if (strncmp(expected_cmd, "AT", 2) == 0){ + printf("\n---> NEXT STEP expect from HF: %s\n", expected_cmd); + while (has_more_hfp_hf_commands()){ + char * ag_cmd = get_next_hfp_hf_command(); + //printf("HF response verify %s == %s[%d]\n", expected_cmd, ag_cmd, expected_cmd_len); + + int equal_cmds = strncmp(ag_cmd, expected_cmd, expected_cmd_len) == 0; + if (!equal_cmds){ + printf("\nError: Expected:'%s', but got:'%s'\n", expected_cmd, ag_cmd); + CHECK_EQUAL(equal_cmds,1); + return; + } + printf("Verified: '%s'\n", expected_cmd); + i++; + if (i < test_item->len){ + expected_cmd = test_steps[i]; + expected_cmd_len = strlen(expected_cmd); + } + } } else { - inject_hfp_command_to_hf((uint8_t*)cmd, strlen(cmd)); + //printf("\n---> NEXT STEP receive from AG: '%s'\n", expected_cmd); + inject_hfp_command_to_hf((uint8_t*)expected_cmd, strlen(expected_cmd)); + i++; } } } void packet_handler(uint8_t * event, uint16_t event_size){ if (event[0] != HCI_EVENT_HFP_META) return; - if (event[3] && event[2] != HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR){ + if (event[3] + && event[2] != HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR + && event[2] != HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG + && event[2] != HFP_SUBEVENT_SPEAKER_VOLUME + && event[2] != HFP_SUBEVENT_MICROPHONE_VOLUME){ printf("ERROR, status: %u\n", event[3]); return; } + switch (event[2]) { case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED: printf("\n** SLC established **\n\n"); @@ -195,6 +431,31 @@ void packet_handler(uint8_t * event, uint16_t event_size){ case HFP_SUBEVENT_CALL_TERMINATED: call_termiated = 1; break; + case HFP_SUBEVENT_COMPLETE: + printf("HFP AG HFP_SUBEVENT_COMPLETE.\n"); + break; + case HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED: + printf("AG_INDICATOR_STATUS_CHANGED, AG indicator '%s' (index: %d) to: %d\n", (const char*) &event[6], event[4], event[5]); + break; + case HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED: + printf("NETWORK_OPERATOR_CHANGED, operator mode: %d, format: %d, name: %s\n", event[4], event[5], (char *) &event[6]); + break; + case HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR: + if (event[4]) + printf("EXTENDED_AUDIO_GATEWAY_ERROR_REPORT, status : %d\n", event[3]); + break; + case HFP_SUBEVENT_RING: + printf("** Ring **\n"); + break; + case HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG: + printf("Phone number for voice tag: %s\n", (const char *) &event[3]); + break; + case HFP_SUBEVENT_SPEAKER_VOLUME: + printf("Speaker volume: %u\n", event[3]); + break; + case HFP_SUBEVENT_MICROPHONE_VOLUME: + printf("Microphone volume: %u\n", event[3]); + break; default: printf("event not handled %u\n", event[2]); break; @@ -202,7 +463,6 @@ void packet_handler(uint8_t * event, uint16_t event_size){ } - TEST_GROUP(HFPClient){ void setup(void){ @@ -225,18 +485,6 @@ TEST_GROUP(HFPClient){ codecs_connection_established = 0; audio_connection_established = 0; } - - void setup_hfp_service_level_connection(hfp_test_item_t * test_item){ - service_level_connection_established = 0; - hfp_hf_establish_service_level_connection(device_addr); - simulate_test_sequence(test_item); - } - - void setup_hfp_codecs_connection(hfp_test_item_t * test_item){ - codecs_connection_established = 0; - simulate_test_sequence(test_item); - } - }; TEST(HFPClient, PTSATATests){ @@ -248,52 +496,11 @@ TEST(HFPClient, PTSATATests){ TEST(HFPClient, PTSSLCTests){ for (int i = 0; i < hfp_pts_hf_slc_tests_size(); i++){ - setup_hfp_service_level_connection(&hfp_pts_hf_slc_tests()[i]); - CHECK_EQUAL(service_level_connection_established, 1); + simulate_test_sequence(&hfp_pts_hf_slc_tests()[i]); teardown(); } } -TEST(HFPClient, HFAudioConnectionEstablishedWithoutCodecNegotiation){ - hfp_hf_init(rfcomm_channel_nr, supported_features_without_codec_negotiation, indicators, sizeof(indicators)/sizeof(uint16_t), 1); - hfp_hf_set_codecs(default_codecs, 1); - - setup_hfp_service_level_connection(&hfp_slc_tests()[1]); - CHECK_EQUAL(service_level_connection_established, 1); - - setup_hfp_codecs_connection(default_hfp_cc_test()); - CHECK_EQUAL(codecs_connection_established, 1); - - hfp_hf_establish_audio_connection(device_addr); - hfp_hf_release_audio_connection(device_addr); - CHECK_EQUAL(audio_connection_established, 0); -} - -TEST(HFPClient, HFCodecsConnectionEstablished){ - for (int i = 0; i < hfp_cc_tests_size(); i++){ - setup_hfp_service_level_connection(default_hfp_slc_test()); - CHECK_EQUAL(service_level_connection_established, 1); - - setup_hfp_codecs_connection(&hfp_cc_tests()[i]); - teardown(); - } -} - -TEST(HFPClient, HFServiceLevelConnectionCommands){ - setup_hfp_service_level_connection(default_hfp_slc_test()); - CHECK_EQUAL(service_level_connection_established, 1); - for (int i = 0; i < hfp_slc_cmds_tests_size(); i++){ - simulate_test_sequence(&hfp_slc_cmds_tests()[i]); - } -} - -TEST(HFPClient, HFServiceLevelConnectionEstablished){ - for (int i = 0; i < hfp_slc_tests_size(); i++){ - setup_hfp_service_level_connection(&hfp_slc_tests()[i]); - CHECK_EQUAL(service_level_connection_established, 1); - teardown(); - } -} int main (int argc, const char * argv[]){ diff --git a/test/hfp/mock.c b/test/hfp/mock.c index 06b19e542..a0e6942ec 100644 --- a/test/hfp/mock.c +++ b/test/hfp/mock.c @@ -101,7 +101,7 @@ char * get_next_hfp_command(int start_command_offset, int end_command_offset){ if ( *(data+i) == '\r' || *(data+i) == '\n' ) { data[i]=0; // update state - // printf("!!! command %s\n", data); + //printf("!!! command %s\n", data); hfp_command_start_index = hfp_command_start_index + i + start_command_offset + end_command_offset; return data; } @@ -110,22 +110,22 @@ char * get_next_hfp_command(int start_command_offset, int end_command_offset){ return NULL; } -// static void print_without_newlines(uint8_t *data, uint16_t len){ -// int found_newline = 0; -// int found_item = 0; +static void print_without_newlines(uint8_t *data, uint16_t len){ + int found_newline = 0; + int found_item = 0; -// for (int i=0; i