diff --git a/include/btstack/hci_cmds.h b/include/btstack/hci_cmds.h index ed0fceb34..a19027866 100644 --- a/include/btstack/hci_cmds.h +++ b/include/btstack/hci_cmds.h @@ -622,10 +622,12 @@ extern "C" { #define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED 0x01 #define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED 0x02 -#define HFP_SUBEVENT_COMPLETE 0x03 -#define HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED 0x04 -#define HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED 0x05 -#define HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR 0x06 +#define HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED 0x03 +#define HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED 0x04 +#define HFP_SUBEVENT_COMPLETE 0x05 +#define HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED 0x06 +#define HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED 0x07 +#define HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR 0x08 // ANCS Client #define ANCS_CLIENT_CONNECTED 0xF0 diff --git a/src/hfp_ag.c b/src/hfp_ag.c index c52825b5c..c15e689e7 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -623,7 +623,7 @@ void hfp_ag_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, h hfp_run_for_context(connection); } -void hfp_ag_transfer_call_status(bd_addr_t bd_addr, hfp_callsetup_status_t status){ +void hfp_ag_transfer_call_status(bd_addr_t bd_addr, hfp_call_status_t status){ hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr); if (!connection){ log_error("HFP HF: connection doesn't exist."); @@ -634,7 +634,7 @@ void hfp_ag_transfer_call_status(bd_addr_t bd_addr, hfp_callsetup_status_t statu } void hfp_ag_transfer_callsetup_status(bd_addr_t bd_addr, hfp_callsetup_status_t status){ - hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr); + hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr); if (!connection){ log_error("HFP HF: connection doesn't exist."); return; @@ -653,3 +653,25 @@ void hfp_ag_transfer_callheld_status(bd_addr_t bd_addr, hfp_callheld_status_t st hfp_ag_update_indicator_status(connection, (char *)"callheld", status); hfp_run_for_context(connection); } + +void hfp_ag_audio_connection_setup(bd_addr_t bd_addr){ + hfp_ag_establish_service_level_connection(bd_addr); + hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr); + if (!connection){ + log_error("HFP HF: connection doesn't exist."); + return; + } + // TODO: + hfp_run_for_context(connection); +} + +void hfp_ag_audio_connection_release(bd_addr_t bd_addr){ + hfp_ag_establish_service_level_connection(bd_addr); + hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr); + if (!connection){ + log_error("HFP HF: connection doesn't exist."); + return; + } + // TODO: + hfp_run_for_context(connection); +} diff --git a/src/hfp_ag.h b/src/hfp_ag.h index ca443cad1..1afb7932c 100644 --- a/src/hfp_ag.h +++ b/src/hfp_ag.h @@ -128,7 +128,7 @@ void hfp_ag_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, h * - 0 = No calls (held or active) * - 1 = Call is present (active or held) */ -void hfp_ag_transfer_call_status(bd_addr_t bd_addr, uint8_t index, hfp_call_status_t status); +void hfp_ag_transfer_call_status(bd_addr_t bd_addr, hfp_call_status_t status); /** * @brief Report the change in AG's call setup status. @@ -138,7 +138,7 @@ void hfp_ag_transfer_call_status(bd_addr_t bd_addr, uint8_t index, hfp_call_stat * - 2 = Outgoing call setup in dialing state * - 3 = Outgoing call setup in alerting state */ -void hfp_ag_transfer_callsetup_status(bd_addr_t bd_addr, uint8_t index, hfp_callsetup_status_t status); +void hfp_ag_transfer_callsetup_status(bd_addr_t bd_addr, hfp_callsetup_status_t status); /** * @brief Report the change in AG's held call status. @@ -147,7 +147,17 @@ void hfp_ag_transfer_callsetup_status(bd_addr_t bd_addr, uint8_t index, hfp_call * - 1 = Call is placed on hold or active/held calls are swapped * - 2 = Call on hold, no active calls */ -void hfp_ag_transfer_callheld_status(bd_addr_t bd_addr, uint8_t index, hfp_callheld_status_t status); +void hfp_ag_transfer_callheld_status(bd_addr_t bd_addr, hfp_callheld_status_t status); + +/** + * @brief + */ +void hfp_ag_audio_connection_setup(bd_addr_t bd_addr); + +/** + * @brief + */ +void hfp_ag_audio_connection_release(bd_addr_t bd_addr); /* API_END */ diff --git a/src/hfp_hf.c b/src/hfp_hf.c index 72783c92b..22d990201 100644 --- a/src/hfp_hf.c +++ b/src/hfp_hf.c @@ -571,3 +571,26 @@ void hfp_hf_enable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_ hfp_run_for_context(connection); } +void hfp_hf_audio_connection_setup(bd_addr_t bd_addr){ + hfp_hf_establish_service_level_connection(bd_addr); + hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr); + if (!connection){ + log_error("HFP HF: connection doesn't exist."); + return; + } + // TODO: + hfp_run_for_context(connection); +} + +void hfp_hf_audio_connection_release(bd_addr_t bd_addr){ + hfp_hf_establish_service_level_connection(bd_addr); + hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr); + if (!connection){ + log_error("HFP HF: connection doesn't exist."); + return; + } + // TODO: + hfp_run_for_context(connection); +} + + diff --git a/src/hfp_hf.h b/src/hfp_hf.h index 76e97cfae..9b957927d 100644 --- a/src/hfp_hf.h +++ b/src/hfp_hf.h @@ -137,6 +137,15 @@ void hfp_hf_query_operator_selection(bd_addr_t bd_addr); */ void hfp_hf_enable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, uint8_t enable); +/** + * @brief + */ +void hfp_hf_audio_connection_setup(bd_addr_t bd_addr); + +/** + * @brief + */ +void hfp_hf_audio_connection_release(bd_addr_t bd_addr); /* API_END */ diff --git a/test/pts/hfp_ag_test.c b/test/pts/hfp_ag_test.c index 957f5dde8..4cd4b53d1 100644 --- a/test/pts/hfp_ag_test.c +++ b/test/pts/hfp_ag_test.c @@ -73,7 +73,7 @@ const char hfp_ag_service_name[] = "BTstack HFP AG Test"; static bd_addr_t device_addr; static bd_addr_t pts_addr = {0x00,0x1b,0xDC,0x07,0x32,0xEF}; -static bd_addr_t speaker = {0x00, 0x21, 0x3C, 0xAC, 0xF7, 0x38}; +static bd_addr_t speaker_addr = {0x00, 0x21, 0x3C, 0xAC, 0xF7, 0x38}; static uint8_t codecs[1] = {HFP_CODEC_CVSD}; static int ag_indicators_nr = 7; @@ -97,27 +97,27 @@ static hfp_generic_status_indicator_t hf_indicators[] = { {2, 1}, }; -uint8_t hfp_connect = 1; char cmd; // prototypes static void show_usage(); static void reset_pst_flags(){ - hfp_connect = 1; } // Testig User Interface static void show_usage(void){ printf("\n--- Bluetooth HFP Hands-Free (HF) unit Test Console ---\n"); printf("---\n"); - if (hfp_connect){ - printf("p - establish HFP connection to PTS module\n"); - printf("c - establish HFP connection to local mac\n"); - } else { - printf("p - release HFP connection to PTS module\n"); - printf("c - release HFP connection to local mac\n"); - } + + printf("a - establish HFP connection to PTS module\n"); + printf("A - release HFP connection to PTS module\n"); + + printf("b - establish AUDIO connection\n"); + printf("B - release AUDIO connection\n"); + + printf("z - establish HFP connection to local mac\n"); + printf("Z - release HFP connection to local mac\n"); printf("d - report AG failure\n"); @@ -129,29 +129,32 @@ static void show_usage(void){ static int stdin_process(struct data_source *ds){ read(ds->fd, &cmd, 1); switch (cmd){ - case 'p': + case 'a': memcpy(device_addr, pts_addr, 6); - if (hfp_connect){ - printf("Establish HFP service level connection to PTS module %s...\n", bd_addr_to_str(device_addr)); - hfp_ag_establish_service_level_connection(device_addr); - } else { - printf("Release HFP service level connection.\n"); - hfp_ag_release_service_level_connection(device_addr); - } - hfp_connect = !hfp_connect; + printf("Establish HFP service level connection to PTS module %s...\n", bd_addr_to_str(device_addr)); + hfp_ag_establish_service_level_connection(device_addr); break; - case 'c': - memcpy(device_addr, speaker, 6); - if (hfp_connect){ - printf("Establish HFP service level connection to %s...\n", bd_addr_to_str(device_addr)); - hfp_ag_establish_service_level_connection(device_addr); - } else { - printf("Release HFP service level connection.\n"); - hfp_ag_release_service_level_connection(device_addr); - } - hfp_connect = !hfp_connect; + case 'A': + printf("Release HFP service level connection.\n"); + hfp_ag_release_service_level_connection(device_addr); + break; + case 'z': + memcpy(device_addr, speaker_addr, 6); + printf("Establish HFP service level connection to %s...\n", bd_addr_to_str(device_addr)); + hfp_ag_establish_service_level_connection(device_addr); + break; + case 'Z': + printf("Release HFP service level connection to %s...\n", bd_addr_to_str(device_addr)); + hfp_ag_release_service_level_connection(device_addr); + break; + case 'b': + printf("Establish Audio connection %s...\n", bd_addr_to_str(device_addr)); + hfp_ag_audio_connection_setup(device_addr); + break; + case 'B': + printf("Release Audio connection.\n"); + hfp_ag_audio_connection_release(device_addr); break; - case 'd': printf("Report AG failure\n"); hfp_ag_report_extended_audio_gateway_error_result_code(device_addr, HFP_CME_ERROR_AG_FAILURE); diff --git a/test/pts/hfp_hf_test.c b/test/pts/hfp_hf_test.c index cda3edee3..52f85ff1c 100644 --- a/test/pts/hfp_hf_test.c +++ b/test/pts/hfp_hf_test.c @@ -82,7 +82,6 @@ static uint16_t indicators[1] = {0x01}; char cmd; uint8_t hfp_enable_extended_audio_gateway_error_report = 1; -uint8_t hfp_connect = 1; uint8_t hfp_enable_status_update_for_all_ag_indicators = 1; // prototypes @@ -90,7 +89,6 @@ static void show_usage(); static void reset_pst_flags(){ hfp_enable_extended_audio_gateway_error_report = 1; - hfp_connect = 1; hfp_enable_status_update_for_all_ag_indicators = 1; } @@ -98,14 +96,16 @@ static void reset_pst_flags(){ static void show_usage(void){ printf("\n--- Bluetooth HFP Hands-Free (HF) unit Test Console ---\n"); printf("---\n"); - if (hfp_connect){ - printf("p - establish HFP connection to PTS module\n"); - printf("c - establish HFP connection to local mac\n"); - } else { - printf("p - release HFP connection to PTS module\n"); - printf("c - release HFP connection to local mac\n"); - } - + + printf("a - establish HFP connection to PTS module\n"); + printf("A - release HFP connection to PTS module\n"); + + printf("b - establish AUDIO connection\n"); + printf("B - release AUDIO connection\n"); + + printf("z - establish HFP connection to local mac\n"); + printf("Z - release HFP connection to local mac\n"); + if (hfp_enable_status_update_for_all_ag_indicators){ printf("d - enable registration status update\n"); } else { @@ -128,28 +128,33 @@ static void show_usage(void){ static int stdin_process(struct data_source *ds){ read(ds->fd, &cmd, 1); switch (cmd){ - case 'p': + case 'a': memcpy(device_addr, pts_addr, 6); - if (hfp_connect){ - printf("Establish HFP service level connection to PTS module %s...\n", bd_addr_to_str(device_addr)); - hfp_hf_establish_service_level_connection(device_addr); - } else { - printf("Release HFP service level connection.\n"); - hfp_hf_release_service_level_connection(device_addr); - } - hfp_connect = !hfp_connect; + printf("Establish HFP service level connection to PTS module %s...\n", bd_addr_to_str(device_addr)); + hfp_hf_establish_service_level_connection(device_addr); break; - case 'c': + case 'A': + printf("Release HFP service level connection.\n"); + hfp_hf_release_service_level_connection(device_addr); + break; + case 'z': memcpy(device_addr, phone_addr, 6); - if (hfp_connect){ - printf("Establish HFP service level connection to %s...\n", bd_addr_to_str(device_addr)); - hfp_hf_establish_service_level_connection(device_addr); - } else { - printf("Release HFP service level connection.\n"); - hfp_hf_release_service_level_connection(device_addr); - } - hfp_connect = !hfp_connect; + printf("Establish HFP service level connection to %s...\n", bd_addr_to_str(device_addr)); + hfp_hf_establish_service_level_connection(device_addr); break; + case 'Z': + printf("Release HFP service level connection to %s...\n", bd_addr_to_str(device_addr)); + hfp_hf_release_service_level_connection(device_addr); + break; + case 'b': + printf("Establish Audio connection %s...\n", bd_addr_to_str(device_addr)); + hfp_hf_audio_connection_setup(device_addr); + break; + case 'B': + printf("Release Audio connection.\n"); + hfp_hf_audio_connection_release(device_addr); + break; + case 'd': if (hfp_enable_status_update_for_all_ag_indicators){ printf("Enable HFP AG registration status update.\n");