mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 01:27:41 +00:00
hfp: handle last dialed number calls
This commit is contained in:
parent
63cfbc853b
commit
930ca5654e
@ -641,8 +641,7 @@ extern "C" {
|
||||
#define HFP_SUBEVENT_STOP_RINGINIG 0x0B
|
||||
#define HFP_SUBEVENT_CALL_TERMINATED 0x0C
|
||||
#define HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER 0x0D
|
||||
|
||||
|
||||
#define HFP_SUBEVENT_REDIAL_LAST_NUMBER 0x0E
|
||||
|
||||
// ANCS Client
|
||||
#define ANCS_CLIENT_CONNECTED 0xF0
|
||||
|
@ -629,6 +629,10 @@ static hfp_command_t parse_command(const char * line_buffer, int isHandsFree){
|
||||
return HFP_CMD_CALL_PHONE_NUMBER;
|
||||
}
|
||||
|
||||
if (strncmp(line_buffer, HFP_REDIAL_LAST_NUMBER, strlen(HFP_REDIAL_LAST_NUMBER)) == 0){
|
||||
return HFP_CMD_REDIAL_LAST_NUMBER;
|
||||
}
|
||||
|
||||
if (strncmp(line_buffer+offset, HFP_CHANGE_IN_BAND_RING_TONE_SETTING, strlen(HFP_CHANGE_IN_BAND_RING_TONE_SETTING)) == 0){
|
||||
return HFP_CMD_CHANGE_IN_BAND_RING_TONE_SETTING;
|
||||
}
|
||||
|
@ -119,6 +119,7 @@ extern "C" {
|
||||
#define HFP_HANG_UP_CALL "+CHUP"
|
||||
#define HFP_CHANGE_IN_BAND_RING_TONE_SETTING "+BSIR"
|
||||
#define HFP_CALL_PHONE_NUMBER "ATD"
|
||||
#define HFP_REDIAL_LAST_NUMBER "AT+BLDN"
|
||||
|
||||
#define HFP_OK "OK"
|
||||
#define HFP_ERROR "ERROR"
|
||||
@ -161,7 +162,8 @@ typedef enum {
|
||||
HFP_CMD_AG_ANSWER_CALL,
|
||||
HFP_CMD_HANG_UP_CALL,
|
||||
HFP_CMD_CHANGE_IN_BAND_RING_TONE_SETTING,
|
||||
HFP_CMD_CALL_PHONE_NUMBER
|
||||
HFP_CMD_CALL_PHONE_NUMBER,
|
||||
HFP_CMD_REDIAL_LAST_NUMBER
|
||||
} hfp_command_t;
|
||||
|
||||
typedef enum {
|
||||
@ -228,6 +230,7 @@ typedef enum {
|
||||
HFP_AG_OUTGOING_CALL_ACCEPTED,
|
||||
HFP_AG_OUTGOING_CALL_RINGING,
|
||||
HFP_AG_OUTGOING_CALL_ESTABLISHED,
|
||||
HFP_AG_OUTGOING_REDIAL_INITIATED,
|
||||
HFP_AG_TERMINATE_CALL_BY_AG,
|
||||
HFP_AG_TERMINATE_CALL_BY_HF,
|
||||
HFP_AG_CALL_DROPPED,
|
||||
|
@ -1001,6 +1001,11 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * connect
|
||||
hfp_emit_string_event(hfp_callback, HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER, (const char *) &connection->line_buffer[3]);
|
||||
break;
|
||||
|
||||
case HFP_AG_OUTGOING_REDIAL_INITIATED:
|
||||
connection->call_state = HFP_CALL_OUTGOING_INITIATED;
|
||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_REDIAL_LAST_NUMBER, 0);
|
||||
break;
|
||||
|
||||
case HFP_AG_OUTGOING_CALL_REJECTED:
|
||||
connection = hfp_ag_connection_for_call_state(HFP_CALL_OUTGOING_INITIATED);
|
||||
if (!connection){
|
||||
@ -1156,6 +1161,9 @@ static void hfp_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uint8_
|
||||
context->command = HFP_CMD_NONE;
|
||||
hfp_ag_call_sm(HFP_AG_OUTGOING_CALL_INITIATED, context);
|
||||
break;
|
||||
case HFP_CMD_REDIAL_LAST_NUMBER:
|
||||
context->command = HFP_CMD_NONE;
|
||||
hfp_ag_call_sm(HFP_AG_OUTGOING_REDIAL_INITIATED, context);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ static bd_addr_t speaker_addr = {0x00, 0x21, 0x3C, 0xAC, 0xF7, 0x38};
|
||||
static uint8_t codecs[1] = {HFP_CODEC_CVSD};
|
||||
static uint16_t handle = -1;
|
||||
static int memory_1_enabled = 1;
|
||||
static int last_number_exists = 1;
|
||||
|
||||
static int ag_indicators_nr = 7;
|
||||
static hfp_ag_indicator_t ag_indicators[] = {
|
||||
@ -142,8 +143,11 @@ static void show_usage(void){
|
||||
|
||||
printf("j - Answering call on remote side\n");
|
||||
|
||||
printf("k - Clear memory #0\n");
|
||||
printf("K - Set memory #0\n");
|
||||
printf("k - Clear memory #1\n");
|
||||
printf("K - Set memory #1\n");
|
||||
|
||||
printf("l - Clear last number\n");
|
||||
printf("L - Set last number\n");
|
||||
|
||||
printf("t - terminate connection\n");
|
||||
|
||||
@ -241,6 +245,14 @@ static int stdin_process(struct data_source *ds){
|
||||
printf("Memory 1 set\n");
|
||||
memory_1_enabled = 1;
|
||||
break;
|
||||
case 'l':
|
||||
printf("Last dialed number cleared\n");
|
||||
last_number_exists = 0;
|
||||
break;
|
||||
case 'L':
|
||||
printf("Last dialed number set\n");
|
||||
last_number_exists = 1;
|
||||
break;
|
||||
case 'j':
|
||||
printf("Answering call on remote side\n");
|
||||
hfp_ag_outgoing_call_established();
|
||||
@ -306,12 +318,26 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
|
||||
|| (memory_1_enabled && strcmp(">1", (char*) &event[3]) == 0)){
|
||||
printf("Dialstring valid: accept call\n");
|
||||
hfp_ag_outgoing_call_accepted();
|
||||
// TODO: calling ringing right away leads to callstatus=2 being skipped. don't call for now
|
||||
// hfp_ag_outgoing_call_ringing();
|
||||
break;
|
||||
} else {
|
||||
printf("Dialstring invalid: reject call\n");
|
||||
hfp_ag_outgoing_call_rejected();
|
||||
}
|
||||
printf("Dialstring invalid: reject call\n");
|
||||
hfp_ag_outgoing_call_rejected();
|
||||
break;
|
||||
case HFP_SUBEVENT_REDIAL_LAST_NUMBER:
|
||||
printf("\n** Redial last number\n");
|
||||
if (last_number_exists){
|
||||
hfp_ag_outgoing_call_accepted();
|
||||
printf("Last number exists: accept call\n");
|
||||
// TODO: calling ringing right away leads to callstatus=2 being skipped. don't call for now
|
||||
// hfp_ag_outgoing_call_ringing();
|
||||
} else {
|
||||
printf("Last number missing: reject call\n");
|
||||
hfp_ag_outgoing_call_rejected();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// printf("event not handled %u\n", event[2]);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user