Merge branch 'bugfix/hf_ag_report_event_with_null_bdaddr' into 'master'

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
This commit is contained in:
Wang Meng Yang
2023-09-04 11:21:15 +08:00
7 changed files with 174 additions and 97 deletions

View File

@@ -64,6 +64,14 @@ typedef enum
ESP_HF_BCS_RESPONSE_EVT, /*!< Final Codec Choice */ ESP_HF_BCS_RESPONSE_EVT, /*!< Final Codec Choice */
} esp_hf_cb_event_t; } 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 /// HFP AG callback parameters
typedef union typedef union
{ {
@@ -97,6 +105,7 @@ typedef union
* @brief ESP_HF_VOLUME_CONTROL_EVT * @brief ESP_HF_VOLUME_CONTROL_EVT
*/ */
struct hf_volume_control_param { 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 */ esp_hf_volume_type_t type; /*!< Volume control target, speaker or microphone */
int volume; /*!< Gain, ranges from 0 to 15 */ int volume; /*!< Gain, ranges from 0 to 15 */
} volume_control; /*!< AG callback param of ESP_HF_VOLUME_CONTROL_EVT */ } volume_control; /*!< AG callback param of ESP_HF_VOLUME_CONTROL_EVT */
@@ -105,48 +114,89 @@ typedef union
* @brief ESP_HF_UNAT_RESPONSE_EVT * @brief ESP_HF_UNAT_RESPONSE_EVT
*/ */
struct hf_unat_rep_param { struct hf_unat_rep_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
char *unat; /*!< Unknown AT command string */ char *unat; /*!< Unknown AT command string */
}unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */ } 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 */
/** /**
* @brief ESP_HF_DIAL_EVT * @brief ESP_HF_DIAL_EVT
*/ */
struct hf_out_call_param { struct hf_out_call_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */ 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 */ char *num_or_loc; /*!< location in phone memory */
} out_call; /*!< AG callback param of ESP_HF_DIAL_EVT */ } 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 * @brief ESP_HF_VTS_RESPONSE_EVT
*/ */
struct hf_vts_rep_param { struct hf_vts_rep_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
char *code; /*!< MTF code from HF Client */ 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 * @brief ESP_HF_NREC_RESPONSE_EVT
*/ */
struct hf_nrec_param { 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 */ } 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 * @brief ESP_HF_WBS_RESPONSE_EVT
*/ */
struct hf_wbs_rep_param { 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 */ esp_hf_wbs_config_t codec; /*!< codec mode CVSD or mSBC */
} wbs_rep; /*!< AG callback param of ESP_HF_WBS_RESPONSE_EVT */ } wbs_rep; /*!< AG callback param of ESP_HF_WBS_RESPONSE_EVT */
@@ -154,6 +204,7 @@ typedef union
* @brief ESP_HF_BCS_RESPONSE_EVT * @brief ESP_HF_BCS_RESPONSE_EVT
*/ */
struct hf_bcs_rep_param { 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 */ esp_hf_wbs_config_t mode; /*!< codec mode CVSD or mSBC */
} bcs_rep; /*!< AG callback param of ESP_HF_BCS_RESPONSE_EVT */ } bcs_rep; /*!< AG callback param of ESP_HF_BCS_RESPONSE_EVT */

View File

@@ -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. * As a precondition to use this API, Service Level Connection shall exist with AG.
* *
* @return * @return

View File

@@ -146,6 +146,14 @@ enum
BTA_AG_HF_CMD_BAC 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 */ /* HFP AT command interpreter table */
const tBTA_AG_AT_CMD bta_ag_hfp_cmd[] = 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: 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*/ /* 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 mem dial cmd, make sure string contains only digits */
if(p_arg[0] == '>') { 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; event = 0;
bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_DSTR); 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') { } else if (p_arg[0] == 'V') {
/* ATDV : Dial VoIP Call */ /* ATDV : Dial VoIP Call */
/* We do not check string. Code will be added later if needed. */ /* 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; event = 0;
bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_SUPPORTED); bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_SUPPORTED);
} }
val.value = BTA_AG_HF_DIAL_VOIP;
} else { } else {
/* If dial cmd, make sure string contains only dial digits /* If dial cmd, make sure string contains only dial digits
** Dial digits are 0-9, A-C, *, #, + */ ** 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; event = 0;
bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_DSTR); 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; break;
} }

View File

@@ -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) 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. */ /* Callout function must free the data. */

View File

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

View File

@@ -214,37 +214,6 @@ static void send_indicator_update(UINT16 indicator, UINT16 value)
BTA_AgResult(BTA_AG_HANDLE_ALL, BTA_AG_IND_RES, &ag_res); BTA_AgResult(BTA_AG_HANDLE_ALL, BTA_AG_IND_RES, &ag_res);
} }
static void btc_hf_cind_evt(tBTA_AG_IND *ind)
{
esp_hf_cb_param_t param;
memset(&param, 0, sizeof(esp_hf_cb_param_t));
switch (ind->type) {
case BTA_AG_IND_CALL:
param.cind.call_status = ind->value;
break;
case BTA_AG_IND_CALLSETUP:
param.cind.call_setup_status = ind->value;
break;
case BTA_AG_IND_SERVICE:
param.cind.svc = ind->value;
break;
case BTA_AG_IND_SIGNAL:
param.cind.signal_strength = ind->value;
break;
case BTA_AG_IND_ROAM:
param.cind.roam = ind->value;
break;
case BTA_AG_IND_BATTCHG:
param.cind.battery_level = ind->value;
break;
case BTA_AG_IND_CALLHELD:
param.cind.call_held_status = ind->value;
break;
}
btc_hf_cb_to_app(ESP_HF_CIND_RESPONSE_EVT, &param);
}
static void bte_hf_evt(tBTA_AG_EVT event, tBTA_AG *param) static void bte_hf_evt(tBTA_AG_EVT event, tBTA_AG *param)
{ {
int param_len = 0; int param_len = 0;
@@ -1225,6 +1194,8 @@ void btc_hf_cb_handler(btc_msg_t *msg)
BTC_TRACE_DEBUG("%s: event = %s", __FUNCTION__, dump_hf_event(event)); BTC_TRACE_DEBUG("%s: event = %s", __FUNCTION__, dump_hf_event(event));
memset(&param, 0, sizeof(esp_hf_cb_param_t));
switch (event) { switch (event) {
case BTA_AG_ENABLE_EVT: case BTA_AG_ENABLE_EVT:
case BTA_AG_DISABLE_EVT: case BTA_AG_DISABLE_EVT:
@@ -1261,7 +1232,6 @@ void btc_hf_cb_handler(btc_msg_t *msg)
} }
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
memcpy(param.conn_stat.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t)); memcpy(param.conn_stat.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t));
param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state; param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state;
param.conn_stat.peer_feat = 0; param.conn_stat.peer_feat = 0;
@@ -1288,7 +1258,6 @@ void btc_hf_cb_handler(btc_msg_t *msg)
hf_local_param[idx].btc_hf_cb.connection_state = ESP_HF_CONNECTION_STATE_SLC_CONNECTED; hf_local_param[idx].btc_hf_cb.connection_state = ESP_HF_CONNECTION_STATE_SLC_CONNECTED;
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state; param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state;
param.conn_stat.peer_feat = hf_local_param[idx].btc_hf_cb.peer_feat; param.conn_stat.peer_feat = hf_local_param[idx].btc_hf_cb.peer_feat;
param.conn_stat.chld_feat = hf_local_param[idx].btc_hf_cb.chld_feat; param.conn_stat.chld_feat = hf_local_param[idx].btc_hf_cb.chld_feat;
@@ -1309,7 +1278,6 @@ void btc_hf_cb_handler(btc_msg_t *msg)
BTC_TRACE_DEBUG("%s: BTA_AG_CLOSE_EVT," "hf_local_param[%d].btc_hf_cb.handle = %d", __FUNCTION__, BTC_TRACE_DEBUG("%s: BTA_AG_CLOSE_EVT," "hf_local_param[%d].btc_hf_cb.handle = %d", __FUNCTION__,
idx, hf_local_param[idx].btc_hf_cb.handle); idx, hf_local_param[idx].btc_hf_cb.handle);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.conn_stat.state = ESP_HF_CONNECTION_STATE_DISCONNECTED; param.conn_stat.state = ESP_HF_CONNECTION_STATE_DISCONNECTED;
param.conn_stat.peer_feat = 0; param.conn_stat.peer_feat = 0;
param.conn_stat.chld_feat = 0; param.conn_stat.chld_feat = 0;
@@ -1328,7 +1296,6 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1; idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx); CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTED; param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTED;
memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t)); memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param); btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
@@ -1341,7 +1308,6 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1; idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx); CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTED_MSBC; param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTED_MSBC;
memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t)); memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param); btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
@@ -1353,7 +1319,6 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1; idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx); CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.audio_stat.state = ESP_HF_AUDIO_STATE_DISCONNECTED; param.audio_stat.state = ESP_HF_AUDIO_STATE_DISCONNECTED;
memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t)); memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param); btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
@@ -1366,8 +1331,8 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1; idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx); CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.vra_rep.value = p_data->val.num; param.vra_rep.value = p_data->val.num;
memcpy(param.vra_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_BVRA_RESPONSE_EVT, &param); btc_hf_cb_to_app(ESP_HF_BVRA_RESPONSE_EVT, &param);
if (p_data->val.num) { if (p_data->val.num) {
btc_hf_connect_audio(&hf_local_param[idx].btc_hf_cb.connected_bda); btc_hf_connect_audio(&hf_local_param[idx].btc_hf_cb.connected_bda);
@@ -1381,8 +1346,10 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_SPK_EVT: case BTA_AG_SPK_EVT:
case BTA_AG_MIC_EVT: case BTA_AG_MIC_EVT:
{ {
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t)); memcpy(param.volume_control.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.volume_control.type = (event == BTA_AG_SPK_EVT) ? ESP_HF_VOLUME_CONTROL_TARGET_SPK : ESP_HF_VOLUME_CONTROL_TARGET_MIC; param.volume_control.type = (event == BTA_AG_SPK_EVT) ? ESP_HF_VOLUME_CONTROL_TARGET_SPK : ESP_HF_VOLUME_CONTROL_TARGET_MIC;
param.volume_control.volume = p_data->val.num; param.volume_control.volume = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_VOLUME_CONTROL_EVT, &param); btc_hf_cb_to_app(ESP_HF_VOLUME_CONTROL_EVT, &param);
@@ -1392,9 +1359,13 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_UNAT_EVT: case BTA_AG_AT_UNAT_EVT:
{ {
memset(&param, 0, sizeof(esp_hf_cb_param_t)); idx = p_data->hdr.handle - 1;
param.unat_rep.unat = p_data->val.str; CHECK_HF_IDX(idx);
btc_hf_cb_to_app(ESP_HF_UNAT_RESPONSE_EVT, &param); do {
memcpy(param.unat_rep.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.unat_rep.unat = p_data->val.str;
btc_hf_cb_to_app(ESP_HF_UNAT_RESPONSE_EVT, &param);
} while (0);
break; break;
} }
@@ -1406,7 +1377,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_CIND_EVT: case BTA_AG_AT_CIND_EVT:
{ {
btc_hf_cind_evt(&p_data->ind); btc_hf_cb_to_app(ESP_HF_CIND_RESPONSE_EVT, NULL);
break; break;
} }
@@ -1430,8 +1401,10 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_VTS_EVT: case BTA_AG_AT_VTS_EVT:
{ {
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t)); memcpy(param.vts_rep.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.vts_rep.code = p_data->val.str; param.vts_rep.code = p_data->val.str;
btc_hf_cb_to_app(ESP_HF_VTS_RESPONSE_EVT, &param); btc_hf_cb_to_app(ESP_HF_VTS_RESPONSE_EVT, &param);
} while(0); } while(0);
@@ -1440,8 +1413,10 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_NREC_EVT: case BTA_AG_AT_NREC_EVT:
{ {
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t)); memcpy(param.nrec.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.nrec.state = p_data->val.num; param.nrec.state = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_NREC_RESPONSE_EVT, &param); btc_hf_cb_to_app(ESP_HF_NREC_RESPONSE_EVT, &param);
} while(0); } while(0);
@@ -1463,16 +1438,20 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_BLDN_EVT: case BTA_AG_AT_BLDN_EVT:
case BTA_AG_AT_D_EVT: case BTA_AG_AT_D_EVT:
{ {
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do { do {
if (event == BTA_AG_AT_D_EVT) { // dial_number_or_memory if (event == BTA_AG_AT_D_EVT) { // dial_number_or_memory
memset(&param, 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)); param.out_call.num_or_loc = osi_malloc((strlen(p_data->val.str) + 1) * sizeof(char));
sprintf(param.out_call.num_or_loc, "%s", p_data->val.str); sprintf(param.out_call.num_or_loc, "%s", p_data->val.str);
btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param); btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param);
send_indicator_update(BTA_AG_IND_CALLSETUP,BTA_AG_CALLSETUP_OUTGOING); send_indicator_update(BTA_AG_IND_CALLSETUP,BTA_AG_CALLSETUP_OUTGOING);
osi_free(param.out_call.num_or_loc); osi_free(param.out_call.num_or_loc);
} else if (event == BTA_AG_AT_BLDN_EVT) { //dial_last } else if (event == BTA_AG_AT_BLDN_EVT) { //dial_last
memset(&param, 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.num_or_loc = NULL;
btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param); btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param);
} }
} while(0); } while(0);
@@ -1515,20 +1494,28 @@ void btc_hf_cb_handler(btc_msg_t *msg)
#if (BTM_WBS_INCLUDED == TRUE) #if (BTM_WBS_INCLUDED == TRUE)
case BTA_AG_WBS_EVT: case BTA_AG_WBS_EVT:
{ {
BTC_TRACE_DEBUG("Set codec status %d codec %d 1=CVSD 2=MSBC", p_data->val.hdr.status, p_data->val.num); idx = p_data->hdr.handle - 1;
memset(&param, 0, sizeof(esp_hf_cb_param_t)); CHECK_HF_IDX(idx);
param.wbs_rep.codec = p_data->val.num; do {
btc_hf_cb_to_app(ESP_HF_WBS_RESPONSE_EVT, &param); BTC_TRACE_DEBUG("Set codec status %d codec %d 1=CVSD 2=MSBC", p_data->val.hdr.status, p_data->val.num);
memcpy(param.wbs_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.wbs_rep.codec = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_WBS_RESPONSE_EVT, &param);
} while (0);
break; break;
} }
case BTA_AG_AT_BCS_EVT: case BTA_AG_AT_BCS_EVT:
{ {
BTC_TRACE_DEBUG("AG final seleded codec is %d 1=CVSD 2=MSBC", p_data->val.num); idx = p_data->hdr.handle - 1;
memset(&param, 0, sizeof(esp_hf_cb_param_t)); CHECK_HF_IDX(idx);
param.bcs_rep.mode = p_data->val.num; do {
/* No ESP_HF_WBS_NONE case, becuase HFP 1.6 supported device can send BCS */ BTC_TRACE_DEBUG("AG final seleded codec is %d 1=CVSD 2=MSBC", p_data->val.num);
btc_hf_cb_to_app(ESP_HF_BCS_RESPONSE_EVT, &param); memcpy(param.bcs_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.bcs_rep.mode = p_data->val.num;
/* No ESP_HF_WBS_NONE case, becuase HFP 1.6 supported device can send BCS */
btc_hf_cb_to_app(ESP_HF_BCS_RESPONSE_EVT, &param);
} while (0);
break; break;
} }
#endif #endif

View File

@@ -275,14 +275,14 @@ void bt_app_send_data_shut_down(void)
vTaskDelete(s_bt_app_send_data_task_handler); vTaskDelete(s_bt_app_send_data_task_handler);
s_bt_app_send_data_task_handler = NULL; s_bt_app_send_data_task_handler = NULL;
} }
if (s_send_data_Semaphore) {
vSemaphoreDelete(s_send_data_Semaphore);
s_send_data_Semaphore = NULL;
}
if(s_periodic_timer) { if(s_periodic_timer) {
ESP_ERROR_CHECK(esp_timer_stop(s_periodic_timer)); ESP_ERROR_CHECK(esp_timer_stop(s_periodic_timer));
ESP_ERROR_CHECK(esp_timer_delete(s_periodic_timer)); ESP_ERROR_CHECK(esp_timer_delete(s_periodic_timer));
} }
if (s_send_data_Semaphore) {
vSemaphoreDelete(s_send_data_Semaphore);
s_send_data_Semaphore = NULL;
}
if (s_m_rb) { if (s_m_rb) {
vRingbufferDelete(s_m_rb); vRingbufferDelete(s_m_rb);
} }
@@ -348,7 +348,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
case ESP_HF_UNAT_RESPONSE_EVT: case ESP_HF_UNAT_RESPONSE_EVT:
{ {
ESP_LOGI(BT_HF_TAG, "--UNKOW AT CMD: %s", param->unat_rep.unat); ESP_LOGI(BT_HF_TAG, "--UNKOW AT CMD: %s", param->unat_rep.unat);
esp_hf_ag_unknown_at_send(hf_peer_addr, NULL); esp_hf_ag_unknown_at_send(param->unat_rep.remote_bda, NULL);
break; break;
} }
@@ -359,7 +359,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
esp_hf_call_setup_status_t call_setup_state = 2; esp_hf_call_setup_status_t call_setup_state = 2;
esp_hf_network_state_t ntk_state = 1; esp_hf_network_state_t ntk_state = 1;
int signal = 2; int signal = 2;
esp_hf_ag_devices_status_indchange(hf_peer_addr,call_state,call_setup_state,ntk_state,signal); esp_hf_ag_devices_status_indchange(param->ind_upd.remote_addr,call_state,call_setup_state,ntk_state,signal);
break; break;
} }
@@ -373,14 +373,14 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
esp_hf_roaming_status_t roam = 0; esp_hf_roaming_status_t roam = 0;
int batt_lev = 3; int batt_lev = 3;
esp_hf_call_held_status_t call_held_status = 0; esp_hf_call_held_status_t call_held_status = 0;
esp_hf_ag_cind_response(hf_peer_addr,call_status,call_setup_status,ntk_state,signal,roam,batt_lev,call_held_status); esp_hf_ag_cind_response(param->cind_rep.remote_addr,call_status,call_setup_status,ntk_state,signal,roam,batt_lev,call_held_status);
break; break;
} }
case ESP_HF_COPS_RESPONSE_EVT: case ESP_HF_COPS_RESPONSE_EVT:
{ {
const int svc_type = 1; const int svc_type = 1;
esp_hf_ag_cops_response(hf_peer_addr, c_operator_name_str[svc_type]); esp_hf_ag_cops_response(param->cops_rep.remote_addr, c_operator_name_str[svc_type]);
break; break;
} }
@@ -397,7 +397,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
esp_hf_call_addr_type_t type = ESP_HF_CALL_ADDR_TYPE_UNKNOWN; esp_hf_call_addr_type_t type = ESP_HF_CALL_ADDR_TYPE_UNKNOWN;
ESP_LOGI(BT_HF_TAG, "--Calling Line Identification."); ESP_LOGI(BT_HF_TAG, "--Calling Line Identification.");
esp_hf_ag_clcc_response(hf_peer_addr, index, dir, current_call_status, mode, mpty, number, type); esp_hf_ag_clcc_response(param->clcc_rep.remote_addr, index, dir, current_call_status, mode, mpty, number, type);
break; break;
} }
@@ -406,7 +406,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
char *number = {"123456"}; char *number = {"123456"};
esp_hf_subscriber_service_type_t type = 1; esp_hf_subscriber_service_type_t type = 1;
ESP_LOGI(BT_HF_TAG, "--Current Number is %s ,Type is %s.", number, c_subscriber_service_type_str[type]); ESP_LOGI(BT_HF_TAG, "--Current Number is %s ,Type is %s.", number, c_subscriber_service_type_str[type]);
esp_hf_ag_cnum_response(hf_peer_addr, number,type); esp_hf_ag_cnum_response(param->cnum_rep.remote_addr, number,type);
break; break;
} }
@@ -426,7 +426,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
{ {
ESP_LOGI(BT_HF_TAG, "--Asnwer Incoming Call."); ESP_LOGI(BT_HF_TAG, "--Asnwer Incoming Call.");
char *number = {"123456"}; char *number = {"123456"};
esp_hf_ag_answer_call(hf_peer_addr,1,0,1,0,number,0); esp_hf_ag_answer_call(param->ata_rep.remote_addr,1,0,1,0,number,0);
break; break;
} }
@@ -434,18 +434,33 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
{ {
ESP_LOGI(BT_HF_TAG, "--Reject Incoming Call."); ESP_LOGI(BT_HF_TAG, "--Reject Incoming Call.");
char *number = {"123456"}; char *number = {"123456"};
esp_hf_ag_reject_call(hf_peer_addr,0,0,0,0,number,0); esp_hf_ag_reject_call(param->chup_rep.remote_addr,0,0,0,0,number,0);
break; break;
} }
case ESP_HF_DIAL_EVT: case ESP_HF_DIAL_EVT:
{ {
if (param->out_call.num_or_loc) { if (param->out_call.num_or_loc) {
//dia_num_or_mem if (param->out_call.type == ESP_HF_DIAL_NUM) {
ESP_LOGI(BT_HF_TAG, "--Dial \"%s\".", param->out_call.num_or_loc); // dia_num
esp_hf_ag_out_call(hf_peer_addr,1,0,1,0,param->out_call.num_or_loc,0); ESP_LOGI(BT_HF_TAG, "--Dial number \"%s\".", param->out_call.num_or_loc);
esp_hf_ag_out_call(param->out_call.remote_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_hf_ag_cmee_send(param->out_call.remote_addr, ESP_HF_AT_RESPONSE_CODE_OK, ESP_HF_CME_AG_FAILURE);
esp_hf_ag_out_call(param->out_call.remote_addr,1,0,1,0,number,0);
} else {
esp_hf_ag_cmee_send(param->out_call.remote_addr, ESP_HF_AT_RESPONSE_CODE_CME, ESP_HF_CME_MEMORY_FAILURE);
}
}
} else { } else {
//dia_last //dia_last
//refer to dia_mem
ESP_LOGI(BT_HF_TAG, "--Dial last number."); ESP_LOGI(BT_HF_TAG, "--Dial last number.");
} }
break; break;