Skip to content

Commit

Permalink
Merge branch 'bugfix/hf_ag_report_event_with_null_bdaddr' into 'master'
Browse files Browse the repository at this point in the history
Bugfix/fixed bugs of HFP in BlueDroid

Closes BTQABR2023-71, BTQABR2023-73, BTQABR2023-74, BTQABR2023-78, BTQABR2023-81, BTQABR2023-82, and BTQABR2023-69

See merge request espressif/esp-idf!25493
  • Loading branch information
wmy-espressif committed Sep 4, 2023
2 parents b1e8540 + cde05ef commit 6598c6e
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 97 deletions.
83 changes: 67 additions & 16 deletions components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ typedef enum
ESP_HF_BCS_RESPONSE_EVT, /*!< Final Codec Choice */
} esp_hf_cb_event_t;

/// Dial type of ESP_HF_DIAL_EVT
typedef enum
{
ESP_HF_DIAL_MEM = 0, /*!< Dial with a memory position */
ESP_HF_DIAL_VOIP, /*!< Dial with VoIP */
ESP_HF_DIAL_NUM, /*!< Dial with a phone number */
} esp_hf_dial_type_t;

/// HFP AG callback parameters
typedef union
{
Expand Down Expand Up @@ -97,6 +105,7 @@ typedef union
* @brief ESP_HF_VOLUME_CONTROL_EVT
*/
struct hf_volume_control_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_hf_volume_type_t type; /*!< Volume control target, speaker or microphone */
int volume; /*!< Gain, ranges from 0 to 15 */
} volume_control; /*!< AG callback param of ESP_HF_VOLUME_CONTROL_EVT */
Expand All @@ -105,55 +114,97 @@ typedef union
* @brief ESP_HF_UNAT_RESPONSE_EVT
*/
struct hf_unat_rep_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
char *unat; /*!< Unknown AT command string */
}unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */

/**
* @brief ESP_HF_CIND_RESPONSE_EVT
*/
struct hf_cind_param {
esp_hf_call_status_t call_status; /*!< call status indicator */
esp_hf_call_setup_status_t call_setup_status; /*!< call setup status indicator */
esp_hf_network_state_t svc; /*!< bluetooth proprietary call hold status indicator */
int signal_strength; /*!< bluetooth proprietary call hold status indicator */
esp_hf_roaming_status_t roam; /*!< bluetooth proprietary call hold status indicator */
int battery_level; /*!< battery charge value, ranges from 0 to 5 */
esp_hf_call_held_status_t call_held_status; /*!< bluetooth proprietary call hold status indicator */
} cind; /*!< AG callback param of ESP_HF_CIND_RESPONSE_EVT */
} unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */

/**
* @brief ESP_HF_DIAL_EVT
*/
struct hf_out_call_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
esp_hf_dial_type_t type; /*!< dial type */
char *num_or_loc; /*!< location in phone memory */
} out_call; /*!< AG callback param of ESP_HF_DIAL_EVT */

/**
* @brief ESP_HF_IND_UPDATE_EVT
*/
struct hf_ind_upd_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} ind_upd; /*!< AG callback param of ESP_HF_IND_UPDATE_EVT */

/**
* @brief ESP_HF_CIND_RESPONSE_EVT
*/
struct hf_cind_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} cind_rep; /*!< AG callback param of ESP_HF_CIND_RESPONSE_EVT */

/**
* @brief ESP_HF_COPS_RESPONSE_EVT
*/
struct hf_cops_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} cops_rep; /*!< AG callback param of ESP_HF_COPS_RESPONSE_EVT */

/**
* @brief ESP_HF_CLCC_RESPONSE_EVT
*/
struct hf_clcc_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} clcc_rep; /*!< AG callback param of ESP_HF_CLCC_RESPONSE_EVT */

/**
* @brief ESP_HF_CNUM_RESPONSE_EVT
*/
struct hf_cnum_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} cnum_rep; /*!< AG callback param of ESP_HF_CNUM_RESPONSE_EVT */

/**
* @brief ESP_HF_VTS_RESPONSE_EVT
*/
struct hf_vts_rep_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
char *code; /*!< MTF code from HF Client */
}vts_rep; /*!< AG callback param of ESP_HF_VTS_RESPONSE_EVT */
} vts_rep; /*!< AG callback param of ESP_HF_VTS_RESPONSE_EVT */

/**
* @brief ESP_HF_NREC_RESPONSE_EVT
*/
struct hf_nrec_param {
esp_hf_nrec_t state; /*!< NREC enabled or disabled */
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_hf_nrec_t state; /*!< NREC enabled or disabled */
} nrec; /*!< AG callback param of ESP_HF_NREC_RESPONSE_EVT */

/**
* @brief ESP_HF_ATA_RESPONSE_EVT
*/
struct hf_ata_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} ata_rep; /*!< AG callback param of ESP_HF_ATA_RESPONSE_EVT */

/**
* @brief ESP_HF_CHUP_RESPONSE_EVT
*/
struct hf_chup_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} chup_rep; /*!< AG callback param of ESP_HF_CHUP_RESPONSE_EVT */

/**
* @brief ESP_HF_WBS_RESPONSE_EVT
*/
struct hf_wbs_rep_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_hf_wbs_config_t codec; /*!< codec mode CVSD or mSBC */
} wbs_rep; /*!< AG callback param of ESP_HF_WBS_RESPONSE_EVT */

/**
* @brief ESP_HF_BCS_RESPONSE_EVT
*/
struct hf_bcs_rep_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_hf_wbs_config_t mode; /*!< codec mode CVSD or mSBC */
} bcs_rep; /*!< AG callback param of ESP_HF_BCS_RESPONSE_EVT */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ esp_err_t esp_hf_client_answer_call(void);

/**
*
* @brief Reject an incoming call(send AT+CHUP command).
* @brief Reject an incoming call or terminate an ongoing call(send AT+CHUP command).
* As a precondition to use this API, Service Level Connection shall exist with AG.
*
* @return
Expand Down
24 changes: 24 additions & 0 deletions components/bt/host/bluedroid/bta/hf_ag/bta_ag_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ enum
BTA_AG_HF_CMD_BAC
};

/* dialing type of BTA_AG_HF_CMD_D */
enum
{
BTA_AG_HF_DIAL_NUM = 0,
BTA_AG_HF_DIAL_VOIP,
BTA_AG_HF_DIAL_MEM,
};

/* HFP AT command interpreter table */
const tBTA_AG_AT_CMD bta_ag_hfp_cmd[] =
{
Expand Down Expand Up @@ -856,27 +864,43 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,

case BTA_AG_HF_CMD_D:
{
UINT16 src = 0;
UINT16 dst = 0;
/* Do not send OK for Dial cmds Let application decide whether to send OK or ERROR*/
/* if mem dial cmd, make sure string contains only digits */
if(p_arg[0] == '>') {
if(!utl_isintstr(p_arg+1)) {
event = 0;
bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_DSTR);
}
val.value = BTA_AG_HF_DIAL_MEM;
src = 1;
} else if (p_arg[0] == 'V') {
/* ATDV : Dial VoIP Call */
/* We do not check string. Code will be added later if needed. */
if(!((p_scb->peer_features & BTA_AG_PEER_FEAT_VOIP) && (p_scb->features & BTA_AG_FEAT_VOIP))) {
event = 0;
bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_SUPPORTED);
}
val.value = BTA_AG_HF_DIAL_VOIP;
} else {
/* If dial cmd, make sure string contains only dial digits
** Dial digits are 0-9, A-C, *, #, + */
if(!utl_isdialstr(p_arg)) {
event = 0;
bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_DSTR);
}
val.value = BTA_AG_HF_DIAL_NUM;
}
if (event != 0) {
while ((val.str[dst] = p_arg[src]) != '\0') {
if (val.str[dst] == ';') {
val.str[dst] = '\0';
break;
}
src++;
dst++;
}
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion components/bt/host/bluedroid/bta/hf_ag/bta_ag_sco.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static void bta_ag_sco_read_cback(UINT16 sco_inx, BT_HDR *p_data, tBTM_SCO_DATA_
{
if (status != BTM_SCO_DATA_CORRECT)
{
APPL_TRACE_WARNING("bta_ag_sco_read_cback: status(%d)", status);
APPL_TRACE_DEBUG("bta_ag_sco_read_cback: status(%d)", status);
}

/* Callout function must free the data. */
Expand Down
16 changes: 8 additions & 8 deletions components/bt/host/bluedroid/bta/include/bta/bta_ag_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ typedef UINT8 tBTA_AG_BTRH_TYPE;
#endif

/* indicator constants HFP 1.1 and later */
#define BTA_AG_IND_CALL 0 /* position of call indicator */
#define BTA_AG_IND_CALLSETUP 1 /* position of callsetup indicator */
#define BTA_AG_IND_SERVICE 2 /* position of service indicator */
#define BTA_AG_IND_CALL 1 /* position of call indicator */
#define BTA_AG_IND_CALLSETUP 2 /* position of callsetup indicator */
#define BTA_AG_IND_SERVICE 3 /* position of service indicator */
/* indicator constants HFP 1.5 and later */
#define BTA_AG_IND_SIGNAL 3 /* position of signal strength indicator */
#define BTA_AG_IND_ROAM 4 /* position of roaming indicator */
#define BTA_AG_IND_BATTCHG 5 /* position of battery charge indicator */
#define BTA_AG_IND_CALLHELD 6 /* position of callheld indicator */
#define BTA_AG_IND_BEARER 7 /* position of bearer indicator */
#define BTA_AG_IND_SIGNAL 4 /* position of signal strength indicator */
#define BTA_AG_IND_ROAM 5 /* position of roaming indicator */
#define BTA_AG_IND_BATTCHG 6 /* position of battery charge indicator */
#define BTA_AG_IND_CALLHELD 7 /* position of callheld indicator */
#define BTA_AG_IND_BEARER 8 /* position of bearer indicator */
typedef UINT16 tBTA_AG_IND_TYPE;

/* call indicator values */
Expand Down
Loading

0 comments on commit 6598c6e

Please sign in to comment.