mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-24 04:43:36 +00:00
hfp: send current call status
This commit is contained in:
parent
a3f9e0cf2d
commit
14738cc203
@ -644,7 +644,7 @@ extern "C" {
|
||||
#define HFP_SUBEVENT_REDIAL_LAST_NUMBER 0x0E
|
||||
#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
|
||||
|
||||
// ANCS Client
|
||||
#define ANCS_CLIENT_CONNECTED 0xF0
|
||||
|
@ -621,6 +621,14 @@ void hfp_handle_hci_event(hfp_callback_t callback, uint8_t packet_type, uint8_t
|
||||
static hfp_command_t parse_command(const char * line_buffer, int isHandsFree){
|
||||
int offset = isHandsFree ? 0 : 2;
|
||||
|
||||
if (strncmp(line_buffer+offset, HFP_LIST_CURRENT_CALLS, strlen(HFP_LIST_CURRENT_CALLS)) == 0){
|
||||
return HFP_CMD_LIST_CURRENT_CALLS;
|
||||
}
|
||||
|
||||
if (strncmp(line_buffer+offset, HFP_SUBSCRIBER_NUMBER_INFORMATION, strlen(HFP_SUBSCRIBER_NUMBER_INFORMATION)) == 0){
|
||||
return HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION;
|
||||
}
|
||||
|
||||
if (strncmp(line_buffer+offset, HFP_PHONE_NUMBER_FOR_VOICE_TAG, strlen(HFP_PHONE_NUMBER_FOR_VOICE_TAG)) == 0){
|
||||
if (isHandsFree) return HFP_CMD_AG_SEND_PHONE_NUMBER;
|
||||
return HFP_CMD_HF_REQUEST_PHONE_NUMBER;
|
||||
|
33
src/hfp.h
33
src/hfp.h
@ -131,6 +131,8 @@ extern "C" {
|
||||
#define HFP_PHONE_NUMBER_FOR_VOICE_TAG "+BINP"
|
||||
#define HFP_TRANSMIT_DTMF_CODES "+VTS"
|
||||
#define HFP_SUBSCRIBER_NUMBER_INFORMATION "+CNUM"
|
||||
#define HFP_LIST_CURRENT_CALLS "+CLCC"
|
||||
|
||||
|
||||
#define HFP_OK "OK"
|
||||
#define HFP_ERROR "ERROR"
|
||||
@ -186,7 +188,9 @@ typedef enum {
|
||||
HFP_CMD_TRANSMIT_DTMF_CODES,
|
||||
HFP_CMD_SET_MICROPHONE_GAIN,
|
||||
HFP_CMD_SET_SPEAKER_GAIN,
|
||||
HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION
|
||||
HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION,
|
||||
HFP_CMD_LIST_CURRENT_CALLS
|
||||
|
||||
} hfp_command_t;
|
||||
|
||||
|
||||
@ -343,6 +347,32 @@ typedef enum {
|
||||
HFP_CALL_OUTGOING_RINGING
|
||||
} hfp_call_state_t;
|
||||
|
||||
typedef enum{
|
||||
HFP_ENHANCED_CALL_DIR_OUTGOING,
|
||||
HFP_ENHANCED_CALL_DIR_INCOMING
|
||||
} hfp_enhanced_call_dir_t;
|
||||
|
||||
typedef enum{
|
||||
HFP_ENHANCED_CALL_STATUS_ACTIVE,
|
||||
HFP_ENHANCED_CALL_STATUS_HELD,
|
||||
HFP_ENHANCED_CALL_STATUS_OUTGOING_DIALING,
|
||||
HFP_ENHANCED_CALL_STATUS_OUTGOING_ALERTING,
|
||||
HFP_ENHANCED_CALL_STATUS_INCOMING,
|
||||
HFP_ENHANCED_CALL_STATUS_INCOMING_WAITING,
|
||||
HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD
|
||||
} hfp_enhanced_call_status_t;
|
||||
|
||||
typedef enum{
|
||||
HFP_ENHANCED_CALL_MODE_VOICE,
|
||||
HFP_ENHANCED_CALL_MODE_DATA,
|
||||
HFP_ENHANCED_CALL_MODE_FAX
|
||||
} hfp_enhanced_call_mode_t;
|
||||
|
||||
typedef enum{
|
||||
HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL,
|
||||
HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL
|
||||
} hfp_enhanced_call_mpty_t;
|
||||
|
||||
typedef enum{
|
||||
HFP_NONE_SM,
|
||||
HFP_SLC_SM,
|
||||
@ -468,6 +498,7 @@ typedef struct hfp_connection {
|
||||
uint8_t send_subscriber_number;
|
||||
int next_subscriber_number_to_send;
|
||||
|
||||
int send_status_of_current_calls;
|
||||
timer_source_t hfp_timeout;
|
||||
} hfp_connection_t;
|
||||
|
||||
|
34
src/hfp_ag.c
34
src/hfp_ag.c
@ -232,7 +232,6 @@ static int hfp_ag_send_phone_number_for_voice_tag_cmd(uint16_t cid){
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
|
||||
static int hfp_ag_send_call_waiting_notification(uint16_t cid){
|
||||
if (!clip_type){
|
||||
clip_number[0] = 0;
|
||||
@ -1239,6 +1238,11 @@ static void hfp_run_for_context(hfp_connection_t *context){
|
||||
if (!context) return;
|
||||
if (!rfcomm_can_send_packet_now(context->rfcomm_cid)) return;
|
||||
|
||||
if (context->send_status_of_current_calls){
|
||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (context->command == HFP_CMD_UNKNOWN){
|
||||
context->ok_pending = 0;
|
||||
context->send_error = 0;
|
||||
@ -1358,6 +1362,11 @@ static void hfp_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uint8_
|
||||
hfp_parse(context, packet[pos], 0);
|
||||
}
|
||||
switch(context->command){
|
||||
case HFP_CMD_LIST_CURRENT_CALLS:
|
||||
context->command = HFP_CMD_NONE;
|
||||
context->send_status_of_current_calls = 1;
|
||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL, 0);
|
||||
break;
|
||||
case HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION:
|
||||
if (subscriber_numbers_count == 0){
|
||||
hfp_ag_ok(context->rfcomm_cid);
|
||||
@ -1799,3 +1808,26 @@ void hfp_ag_set_subcriber_number_information(hfp_phone_number_t * numbers, int n
|
||||
subscriber_numbers = numbers;
|
||||
subscriber_numbers_count = numbers_count;
|
||||
}
|
||||
|
||||
void hfp_ag_send_current_call_status(bd_addr_t bd_addr, int idx, hfp_enhanced_call_dir_t dir,
|
||||
hfp_enhanced_call_status_t status, hfp_enhanced_call_mode_t mode,
|
||||
hfp_enhanced_call_mpty_t mpty, uint8_t type, const char * number){
|
||||
|
||||
hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
|
||||
char buffer[100];
|
||||
int offset = snprintf(buffer, sizeof(buffer), "\r\n%s:%d,%d,%d,%d,%d", HFP_LIST_CURRENT_CALLS, idx, dir, status, mode, mpty);
|
||||
if (number){
|
||||
offset += snprintf(buffer+offset, sizeof(buffer)-offset, "\"%s\",%u", number, type);
|
||||
}
|
||||
snprintf(buffer+offset, sizeof(buffer)-offset, "\r\n");
|
||||
send_str_over_rfcomm(connection->rfcomm_cid, buffer);
|
||||
}
|
||||
|
||||
|
||||
void hfp_ag_send_current_call_status_done(bd_addr_t bd_addr){
|
||||
hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
connection->ok_pending = 1;
|
||||
connection->send_status_of_current_calls = 0;
|
||||
}
|
||||
|
||||
|
@ -275,6 +275,15 @@ void hfp_ag_send_dtmf_code_done(bd_addr_t bd_addr);
|
||||
*/
|
||||
void hfp_ag_set_subcriber_number_information(hfp_phone_number_t * numbers, int numbers_count);
|
||||
|
||||
/*
|
||||
* @brief
|
||||
*/
|
||||
void hfp_ag_send_current_call_status(bd_addr_t bd_addr, int idx, hfp_enhanced_call_dir_t dir,
|
||||
hfp_enhanced_call_status_t status, hfp_enhanced_call_mode_t mode,
|
||||
hfp_enhanced_call_mpty_t mpty, uint8_t type, const char * number);
|
||||
|
||||
void hfp_ag_send_current_call_status_done(bd_addr_t bd_addr);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user