mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(bt/bluedroid): Fixed errors in parsing ATD command in HFP AG
This commit is contained in:
parent
7db846e809
commit
68e469d55f
@ -72,6 +72,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
|
||||
{
|
||||
@ -134,6 +142,7 @@ typedef union
|
||||
*/
|
||||
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 */
|
||||
|
||||
|
@ -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[] =
|
||||
{
|
||||
@ -856,6 +864,8 @@ 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] == '>') {
|
||||
@ -863,6 +873,8 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
|
||||
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. */
|
||||
@ -870,6 +882,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
|
||||
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, *, #, + */
|
||||
@ -877,6 +890,17 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
|
||||
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;
|
||||
}
|
||||
|
@ -1458,6 +1458,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
|
||||
if (event == BTA_AG_AT_D_EVT && p_data->val.str) { // dial_number_or_memory
|
||||
memset(¶m, 0, sizeof(esp_hf_cb_param_t));
|
||||
memcpy(param.out_call.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
|
||||
param.out_call.type = p_data->val.value;
|
||||
param.out_call.num_or_loc = osi_malloc((strlen(p_data->val.str) + 1) * sizeof(char));
|
||||
sprintf(param.out_call.num_or_loc, p_data->val.str);
|
||||
btc_hf_cb_to_app(ESP_HF_DIAL_EVT, ¶m);
|
||||
|
@ -442,11 +442,26 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
|
||||
case ESP_HF_DIAL_EVT:
|
||||
{
|
||||
if (param->out_call.num_or_loc) {
|
||||
//dia_num_or_mem
|
||||
ESP_LOGI(BT_HF_TAG, "--Dial \"%s\".", param->out_call.num_or_loc);
|
||||
esp_bt_hf_out_call(hf_peer_addr,1,0,1,0,param->out_call.num_or_loc,0);
|
||||
if (param->out_call.type == ESP_HF_DIAL_NUM) {
|
||||
// dia_num
|
||||
ESP_LOGI(BT_HF_TAG, "--Dial number \"%s\".", param->out_call.num_or_loc);
|
||||
esp_bt_hf_out_call(hf_peer_addr,1,0,1,0,param->out_call.num_or_loc,0);
|
||||
} else if (param->out_call.type == ESP_HF_DIAL_MEM) {
|
||||
// dia_mem
|
||||
ESP_LOGI(BT_HF_TAG, "--Dial memory \"%s\".", param->out_call.num_or_loc);
|
||||
// AG found phone number by memory position
|
||||
bool num_found = true;
|
||||
if (num_found) {
|
||||
char *number = "123456";
|
||||
esp_bt_hf_cmee_response(hf_peer_addr, ESP_HF_AT_RESPONSE_CODE_OK, ESP_HF_CME_AG_FAILURE);
|
||||
esp_bt_hf_out_call(hf_peer_addr,1,0,1,0,number,0);
|
||||
} else {
|
||||
esp_bt_hf_cmee_response(hf_peer_addr, ESP_HF_AT_RESPONSE_CODE_CME, ESP_HF_CME_MEMEORY_FAILURE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//dia_last
|
||||
//refer to dia_mem
|
||||
ESP_LOGI(BT_HF_TAG, "--Dial last number.");
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user