hfp: add HF hangup call

This commit is contained in:
Matthias Ringwald 2015-11-27 14:08:11 +01:00
parent 66ee7d3e0b
commit 78747ec155
4 changed files with 38 additions and 8 deletions

View File

@ -538,6 +538,7 @@ typedef struct hfp_connection {
hfp_hf_query_operator_state_t hf_query_operator_state;
uint8_t hf_answer_incoming_call;
uint8_t hf_send_clip_enable;
uint8_t hf_send_chup;
} hfp_connection_t;

View File

@ -242,6 +242,12 @@ static int hfp_hf_send_clip_enable(uint16_t cid){
return send_str_over_rfcomm(cid, buffer);
}
static int hfp_hf_send_chup(uint16_t cid){
char buffer[20];
sprintf(buffer, "AT%s\r\n", HFP_HANG_UP_CALL);
return send_str_over_rfcomm(cid, buffer);
}
static void hfp_emit_ag_indicator_event(hfp_callback_t callback, int status, hfp_ag_indicator_t indicator){
if (!callback) return;
uint8_t event[6+HFP_MAX_INDICATOR_DESC_SIZE+1];
@ -339,13 +345,6 @@ static int hfp_hf_run_for_context_service_level_connection_queries(hfp_connectio
return done;
}
if (context->hf_send_clip_enable){
context->hf_send_clip_enable = 0;
context->ok_pending = 1;
hfp_hf_send_clip_enable(context->rfcomm_cid);
return 1;
}
switch (context->hf_query_operator_state){
case HFP_HF_QUERY_OPERATOR_SET_FORMAT:
context->hf_query_operator_state = HFP_HF_QUERY_OPERATOR_W4_SET_FORMAT_OK;
@ -476,6 +475,20 @@ static void hfp_run_for_context(hfp_connection_t * context){
done = call_setup_state_machine(context);
}
if (context->hf_send_clip_enable){
context->hf_send_clip_enable = 0;
context->ok_pending = 1;
hfp_hf_send_clip_enable(context->rfcomm_cid);
return;
}
if (context->hf_send_chup){
context->hf_send_chup = 0;
context->ok_pending = 1;
hfp_hf_send_chup(context->rfcomm_cid);
return;
}
if (done) return;
// deal with disconnect
switch (context->state){
@ -834,6 +847,13 @@ void hfp_hf_answer_incoming_call(bd_addr_t bd_addr){
// }
}
void hfp_hf_terminate_call(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);
connection->hf_send_chup = 1;
hfp_run_for_context(connection);
}
void hfp_hf_enable_calling_line_identification(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);

View File

@ -84,7 +84,6 @@ void hfp_hf_register_packet_handler(hfp_callback_t callback);
*/
void hfp_hf_establish_service_level_connection(bd_addr_t bd_addr);
/**
* @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
* TODO: trigger release of the audio connection
@ -155,6 +154,11 @@ void hfp_hf_release_audio_connection(bd_addr_t bd_addr);
*/
void hfp_hf_answer_incoming_call(bd_addr_t bd_addr);
/**
* @brief
*/
void hfp_hf_terminate_call(bd_addr_t bd_addr);
/**
* @brief
*/

View File

@ -109,6 +109,7 @@ static void show_usage(void){
printf("e - disable reporting of the extended AG error result code\n");
printf("f - answer incoming call\n");
printf("F - Hangup call\n");
printf("g - query network operator name\n");
printf("h - enable Calling Line Identification.\n");
@ -166,6 +167,10 @@ static int stdin_process(struct data_source *ds){
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("Query operator.\n");
hfp_hf_query_operator_selection(device_addr);