hfp: suppor Response and Hold in HF tester

This commit is contained in:
Matthias Ringwald 2015-11-28 16:41:27 +01:00
parent 4b60c8c50d
commit 7c1eb74b34
5 changed files with 120 additions and 6 deletions

View File

@ -732,10 +732,10 @@ static hfp_command_t parse_command(const char * line_buffer, int isHandsFree){
if (strncmp(line_buffer+strlen(HFP_RESPONSE_AND_HOLD)+offset, "?", 1) == 0){
return HFP_CMD_RESPONSE_AND_HOLD_QUERY;
}
if (strncmp(line_buffer+strlen(HFP_RESPONSE_AND_HOLD)+offset, "=", 1) == 0){
return HFP_CMD_RESPONSE_AND_HOLD_COMMAND;
}
return HFP_CMD_RESPONSE_AND_HOLD_STATUS;
}
if (strncmp(line_buffer+offset, HFP_INDICATOR, strlen(HFP_INDICATOR)) == 0){

View File

@ -195,6 +195,7 @@ typedef enum {
HFP_CMD_LIST_CURRENT_CALLS,
HFP_CMD_RESPONSE_AND_HOLD_QUERY,
HFP_CMD_RESPONSE_AND_HOLD_COMMAND,
HFP_CMD_RESPONSE_AND_HOLD_STATUS,
HFP_CMD_HF_INDICATOR_STATUS
} hfp_command_t;
@ -568,6 +569,8 @@ typedef struct hfp_connection {
char hf_send_dtmf_code;
uint8_t hf_send_binp;
uint8_t hf_send_clcc;
uint8_t hf_send_rrh;
char hf_send_rrh_command;
uint8_t hf_activate_call_waiting_notification;
uint8_t hf_deactivate_call_waiting_notification;

View File

@ -714,6 +714,26 @@ static void hfp_run_for_context(hfp_connection_t * context){
return;
}
if (context->hf_send_rrh){
context->hf_send_rrh = 0;
char buffer[20];
switch (context->hf_send_rrh_command){
case '?':
sprintf(buffer, "AT%s?\r\n", HFP_RESPONSE_AND_HOLD);
send_str_over_rfcomm(context->rfcomm_cid, buffer);
return;
case '0':
case '1':
case '2':
sprintf(buffer, "AT%s=%c\r\n", HFP_RESPONSE_AND_HOLD, context->hf_send_rrh_command);
send_str_over_rfcomm(context->rfcomm_cid, buffer);
return;
default:
break;
}
return;
}
if (done) return;
// deal with disconnect
switch (context->state){
@ -873,7 +893,12 @@ static void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8
}
switch (context->command){
case HFP_CMD_RESPONSE_AND_HOLD_STATUS:
context->command = HFP_CMD_NONE;
printf("Response and Hold status: %s\n", context->line_buffer);
break;
case HFP_CMD_LIST_CURRENT_CALLS:
context->command = HFP_CMD_NONE;
printf("Enhanced Call Status: idx %u, dir %u, status %u, mpty %u, number %s, type %u\n",
context->clcc_idx, context->clcc_dir, context->clcc_status, context->clcc_mpty,
context->bnip_number, context->bnip_type);
@ -1390,3 +1415,47 @@ void hfp_hf_query_current_call_status(bd_addr_t addr){
}
/*
* @brief
*/
void hfp_hf_rrh_query_status(bd_addr_t addr){
hfp_hf_establish_service_level_connection(addr);
hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(addr);
connection->hf_send_rrh = 1;
connection->hf_send_rrh_command = '?';
hfp_run_for_context(connection);
}
/*
* @brief
*/
void hfp_hf_rrh_hold_call(bd_addr_t addr){
hfp_hf_establish_service_level_connection(addr);
hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(addr);
connection->hf_send_rrh = 1;
connection->hf_send_rrh_command = '0';
hfp_run_for_context(connection);
}
/*
* @brief
*/
void hfp_hf_rrh_accept_held_call(bd_addr_t addr){
hfp_hf_establish_service_level_connection(addr);
hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(addr);
connection->hf_send_rrh = 1;
connection->hf_send_rrh_command = '1';
hfp_run_for_context(connection);
}
/*
* @brief
*/
void hfp_hf_rrh_reject_held_call(bd_addr_t addr)
{
hfp_hf_establish_service_level_connection(addr);
hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(addr);
connection->hf_send_rrh = 1;
connection->hf_send_rrh_command = '2';
hfp_run_for_context(connection);
}

View File

@ -280,6 +280,26 @@ void hfp_hf_release_call_with_index(bd_addr_t addr, int index);
*/
void hfp_hf_private_consultation_with_call(bd_addr_t addr, int index);
/*
* @brief
*/
void hfp_hf_rrh_query_status(bd_addr_t addr);
/*
* @brief
*/
void hfp_hf_rrh_hold_call(bd_addr_t addr);
/*
* @brief
*/
void hfp_hf_rrh_accept_held_call(bd_addr_t addr);
/*
* @brief
*/
void hfp_hf_rrh_reject_held_call(bd_addr_t addr);
/* API_END */
#if defined __cplusplus

View File

@ -144,12 +144,13 @@ static void show_usage(void){
printf("t - terminate connection\n");
printf("u - send 'user busy' (Three-Way Call 0)\n");
printf("U - end active call and accept other call' (Three-Way Call 1)\n");
printf("v - Swap active call and hold/waiting call (Three-Way Call 2)\n");
printf("V - Join held call (Three-Way Call 3)\n");
printf("w - Connect calls (Three-Way Call 4)\n");
printf("u - send 'user busy' (TWC 0)\n");
printf("U - end active call and accept other call' (TWC 1)\n");
printf("v - Swap active call and hold/waiting call (TWC 2)\n");
printf("V - Join held call (TWC 3)\n");
printf("w - Connect calls (TWC 4)\n");
printf("W - redial\n");
printf("0123456789#*-+ - send DTMF dial tones\n");
printf("x - request phone number for voice tag\n");
@ -157,6 +158,11 @@ static void show_usage(void){
printf("y - release call with index 2 (ECC)\n");
printf("Y - private consulation with call 2(ECC)\n");
printf("[ - Query Response and Hold status (RHH ?)\n");
printf("] - Place call in a response and held state(RHH 0)\n");
printf("{ - Accept held call(RHH 1)\n");
printf("} - Reject held call(RHH 2)\n");
printf("---\n");
printf("Ctrl-c - exit\n");
printf("---\n");
@ -362,6 +368,22 @@ static int stdin_process(struct data_source *ds){
memcpy(device_addr, phone_addr, 6);
printf("Use iPhone %s as Audiogateway.\n", bd_addr_to_str(device_addr));
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;
default:
show_usage();
break;