diff --git a/include/btstack/hci_cmds.h b/include/btstack/hci_cmds.h index 4cf2a3efe..05609c20c 100644 --- a/include/btstack/hci_cmds.h +++ b/include/btstack/hci_cmds.h @@ -645,6 +645,8 @@ extern "C" { #define HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG 0x0F #define HFP_SUBEVENT_TRANSMIT_DTMF_CODES 0x10 #define HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL 0x11 +#define HFP_SUBEVENT_CALL_ANSWERED 0x12 +#define HFP_SUBEVENT_CONFERENCE_CALL 0x13 // ANCS Client #define ANCS_CLIENT_CONNECTED 0xF0 diff --git a/src/hfp_ag.c b/src/hfp_ag.c index dbd6b3751..b1cbb981e 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -1072,6 +1072,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * connect hfp_ag_set_call_state(HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT); hfp_ag_hf_accept_call(connection); printf("HF answers call, accept call by GSM\n"); + hfp_emit_event(hfp_callback, HFP_CMD_CALL_ANSWERED, 0); break; default: break; @@ -1476,6 +1477,7 @@ static void hfp_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uint8_ printf("AG: Join 3-way-call\n"); hfp_ag_set_callheld_state(HFP_CALLHELD_STATUS_NO_CALLS_HELD); context->ag_indicators_status_update_bitmap = store_bit(context->ag_indicators_status_update_bitmap, callheld_indicator_index, 1); + hfp_emit_event(hfp_callback, HFP_SUBEVENT_CONFERENCE_CALL, 0); } context->call_state = HFP_CALL_ACTIVE; break; diff --git a/test/pts/hfp_ag_test.c b/test/pts/hfp_ag_test.c index d14b50a64..0fca0e67a 100644 --- a/test/pts/hfp_ag_test.c +++ b/test/pts/hfp_ag_test.c @@ -83,7 +83,8 @@ static int current_call_index = 0; static hfp_enhanced_call_dir_t current_call_dir; static int current_call_exists_a = 0; static int current_call_exists_b = 0; -static hfp_enhanced_call_status_t current_call_status; +static hfp_enhanced_call_status_t current_call_status_a; +static hfp_enhanced_call_status_t current_call_status_b; static hfp_enhanced_call_mpty_t current_call_mpty = HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL; @@ -212,16 +213,16 @@ static int stdin_process(struct data_source *ds){ case 'c': printf("Simulate incoming call from 1234567\n"); current_call_exists_a = 1; + current_call_status_a = HFP_ENHANCED_CALL_STATUS_INCOMING; current_call_dir = HFP_ENHANCED_CALL_DIR_INCOMING; - current_call_status = HFP_ENHANCED_CALL_STATUS_INCOMING; hfp_ag_set_clip(129, "1234567"); hfp_ag_incoming_call(); break; case 'm': printf("Simulate incoming call from 7654321\n"); current_call_exists_b = 1; + current_call_status_b = HFP_ENHANCED_CALL_STATUS_INCOMING; current_call_dir = HFP_ENHANCED_CALL_DIR_INCOMING; - current_call_status = HFP_ENHANCED_CALL_STATUS_INCOMING; hfp_ag_set_clip(129, "7654321"); hfp_ag_incoming_call(); break; @@ -235,7 +236,12 @@ static int stdin_process(struct data_source *ds){ break; case 'e': printf("Answer call on AG\n"); - current_call_status = HFP_ENHANCED_CALL_STATUS_ACTIVE; + if (current_call_status_a == HFP_ENHANCED_CALL_STATUS_INCOMING){ + current_call_status_a = HFP_ENHANCED_CALL_STATUS_ACTIVE; + } + if (current_call_status_b == HFP_ENHANCED_CALL_STATUS_INCOMING){ + current_call_status_b = HFP_ENHANCED_CALL_STATUS_ACTIVE; + } hfp_ag_answer_incoming_call(); break; case 'E': @@ -349,7 +355,6 @@ static int stdin_process(struct data_source *ds){ case 'u': printf("Join held call\n"); current_call_mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL; - current_call_status = HFP_ENHANCED_CALL_STATUS_ACTIVE; hfp_ag_join_held_call(); break; default: @@ -436,19 +441,33 @@ static void packet_handler(uint8_t * event, uint16_t event_size){ break; case HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL: if (current_call_index == 0 && current_call_exists_a){ - hfp_ag_send_current_call_status(device_addr, 1, current_call_dir, current_call_status, + hfp_ag_send_current_call_status(device_addr, 1, current_call_dir, current_call_status_a, HFP_ENHANCED_CALL_MODE_VOICE, current_call_mpty, 129, "1234567"); current_call_index = 1; break; } if (current_call_index == 1 && current_call_exists_b){ - hfp_ag_send_current_call_status(device_addr, 2, current_call_dir, current_call_status, + hfp_ag_send_current_call_status(device_addr, 2, current_call_dir, current_call_status_b, HFP_ENHANCED_CALL_MODE_VOICE, current_call_mpty, 129, "7654321"); current_call_index = 2; break; } hfp_ag_send_current_call_status_done(device_addr); break; + case HFP_CMD_CALL_ANSWERED: + printf("Call answered by HF\n"); + if (current_call_status_a == HFP_ENHANCED_CALL_STATUS_INCOMING){ + current_call_status_a = HFP_ENHANCED_CALL_STATUS_ACTIVE; + } + if (current_call_status_b == HFP_ENHANCED_CALL_STATUS_INCOMING){ + current_call_status_b = HFP_ENHANCED_CALL_STATUS_ACTIVE; + } + break; + case HFP_SUBEVENT_CONFERENCE_CALL: + current_call_mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL; + current_call_status_a = HFP_ENHANCED_CALL_STATUS_ACTIVE; + current_call_status_b = HFP_ENHANCED_CALL_STATUS_ACTIVE; + break; default: printf("Event not handled %u\n", event[2]); break;