mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 01:27:41 +00:00
hfp hf: dial, redial, memory dial
This commit is contained in:
parent
56f716feca
commit
1a77991a3f
@ -539,6 +539,10 @@ typedef struct hfp_connection {
|
||||
// HF only
|
||||
hfp_hf_query_operator_state_t hf_query_operator_state;
|
||||
uint8_t hf_answer_incoming_call;
|
||||
uint8_t hf_initiate_outgoing_call;
|
||||
uint8_t hf_initiate_memory_dialing;
|
||||
uint8_t hf_initiate_redial_last_number;
|
||||
|
||||
uint8_t hf_send_clip_enable;
|
||||
uint8_t hf_send_chup;
|
||||
|
||||
|
68
src/hfp_hf.c
68
src/hfp_hf.c
@ -77,6 +77,8 @@ static hfp_call_status_t hfp_call_status;
|
||||
static hfp_callsetup_status_t hfp_callsetup_status;
|
||||
static hfp_callheld_status_t hfp_callheld_status;
|
||||
|
||||
static char phone_number[25];
|
||||
|
||||
void hfp_hf_register_packet_handler(hfp_callback_t callback){
|
||||
hfp_callback = callback;
|
||||
if (callback == NULL){
|
||||
@ -242,6 +244,24 @@ static int hfp_hf_send_clip_enable(uint16_t cid){
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
static int hfp_hf_initiate_outgoing_call_cmd(uint16_t cid){
|
||||
char buffer[40];
|
||||
sprintf(buffer, "%s%s;\r\n", HFP_CALL_PHONE_NUMBER, phone_number);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
static int hfp_hf_send_memory_dial_cmd(uint16_t cid){
|
||||
char buffer[40];
|
||||
sprintf(buffer, "%s>%s;\r\n", HFP_CALL_PHONE_NUMBER, phone_number);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
static int hfp_hf_send_redial_last_number_cmd(uint16_t cid){
|
||||
char buffer[20];
|
||||
sprintf(buffer, "%s\r\n", HFP_REDIAL_LAST_NUMBER);
|
||||
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);
|
||||
@ -475,6 +495,28 @@ static void hfp_run_for_context(hfp_connection_t * context){
|
||||
done = call_setup_state_machine(context);
|
||||
}
|
||||
|
||||
|
||||
if (context->hf_initiate_outgoing_call){
|
||||
context->hf_initiate_outgoing_call = 0;
|
||||
context->ok_pending = 1;
|
||||
hfp_hf_initiate_outgoing_call_cmd(context->rfcomm_cid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (context->hf_initiate_memory_dialing){
|
||||
context->hf_initiate_memory_dialing = 0;
|
||||
context->ok_pending = 1;
|
||||
hfp_hf_send_memory_dial_cmd(context->rfcomm_cid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (context->hf_initiate_redial_last_number){
|
||||
context->hf_initiate_redial_last_number = 0;
|
||||
context->ok_pending = 1;
|
||||
hfp_hf_send_redial_last_number_cmd(context->rfcomm_cid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (context->hf_send_clip_enable){
|
||||
context->hf_send_clip_enable = 0;
|
||||
context->ok_pending = 1;
|
||||
@ -883,3 +925,29 @@ void hfp_hf_enable_calling_line_identification(bd_addr_t bd_addr){
|
||||
connection->hf_send_clip_enable = 1;
|
||||
hfp_run_for_context(connection);
|
||||
}
|
||||
|
||||
void hfp_hf_dial_number(bd_addr_t bd_addr, char * number){
|
||||
hfp_hf_establish_service_level_connection(bd_addr);
|
||||
hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
|
||||
connection->hf_initiate_outgoing_call = 1;
|
||||
snprintf(phone_number, sizeof(phone_number), "%s", number);
|
||||
hfp_run_for_context(connection);
|
||||
}
|
||||
|
||||
void hfp_hf_dial_memory(bd_addr_t bd_addr, char * number){
|
||||
hfp_hf_establish_service_level_connection(bd_addr);
|
||||
hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
|
||||
connection->hf_initiate_memory_dialing = 1;
|
||||
snprintf(phone_number, sizeof(phone_number), "%s", number);
|
||||
hfp_run_for_context(connection);
|
||||
}
|
||||
|
||||
void hfp_hf_redial_last_number(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_initiate_redial_last_number = 1;
|
||||
hfp_run_for_context(connection);
|
||||
}
|
||||
|
15
src/hfp_hf.h
15
src/hfp_hf.h
@ -169,6 +169,21 @@ void hfp_hf_terminate_call(bd_addr_t bd_addr);
|
||||
*/
|
||||
void hfp_hf_enable_calling_line_identification(bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
void hfp_hf_dial_number(bd_addr_t bd_addr, char * number);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
void hfp_hf_dial_memory(bd_addr_t bd_addr, char * number);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
void hfp_hf_redial_last_number(bd_addr_t bd_addr);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -99,23 +99,29 @@ static void show_usage(void){
|
||||
printf("b - establish Audio connection\n");
|
||||
printf("B - release Audio connection\n");
|
||||
|
||||
printf("C - enable registration status update for all AG indicators\n");
|
||||
printf("c - disable registration status update for all AG indicators\n");
|
||||
printf("C - enable registration status update for all AG indicators\n");
|
||||
|
||||
printf("D - set HFP AG registration status update for individual indicators\n");
|
||||
printf("d - Query network operator.\n");
|
||||
printf("D - set HFP AG registration status update for individual indicators\n");
|
||||
|
||||
printf("E - enable reporting of the extended AG error result code\n");
|
||||
printf("e - disable reporting of the extended AG error result code\n");
|
||||
printf("E - enable reporting of the extended AG error result code\n");
|
||||
|
||||
printf("f - answer incoming call\n");
|
||||
printf("F - Hangup call\n");
|
||||
|
||||
printf("G - Reject call.\n");
|
||||
printf("g - query network operator name\n");
|
||||
printf("G - Reject call.\n");
|
||||
|
||||
printf("h - enable Calling Line Identification.\n");
|
||||
|
||||
printf("i - dial 1234567\n");
|
||||
printf("I - redial\n");
|
||||
|
||||
printf("j - dial #1\n");
|
||||
printf("J - dial #99\n");
|
||||
|
||||
printf("t - terminate connection\n");
|
||||
|
||||
printf("---\n");
|
||||
@ -193,6 +199,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 'i':
|
||||
printf("Dial 1234567\n");
|
||||
hfp_hf_dial_number(device_addr, "1234567");
|
||||
break;
|
||||
case 'I':
|
||||
printf("Redial\n");
|
||||
hfp_hf_redial_last_number(device_addr);
|
||||
break;
|
||||
case 'j':
|
||||
printf("Dial #1\n");
|
||||
hfp_hf_dial_memory(device_addr,"#1");
|
||||
break;
|
||||
case 'J':
|
||||
printf("Dial #99\n");
|
||||
hfp_hf_dial_memory(device_addr,"#99");
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user