fix(bt/bluedroid): Fixed the issue of NULL address for btc_hf_ag

This commit is contained in:
chenqingqing 2023-09-04 16:29:11 +08:00
parent ad65d70b5b
commit 55cdf8434b
3 changed files with 41 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -76,7 +76,7 @@ typedef enum
typedef union
{
/**
* @brief ESP_HS_CONNECTION_STATE_EVT
* @brief ESP_HF_CONNECTION_STATE_EVT
*/
struct hf_conn_stat_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
@ -105,7 +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_bd_addr_t remote_addr; /*!< 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 */
@ -114,7 +114,7 @@ typedef union
* @brief ESP_HF_UNAT_RESPONSE_EVT
*/
struct hf_unat_rep_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
char *unat; /*!< Unknown AT command string */
} unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */
@ -166,7 +166,7 @@ typedef union
* @brief ESP_HF_VTS_RESPONSE_EVT
*/
struct hf_vts_rep_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
char *code; /*!< MTF code from HF Client */
} vts_rep; /*!< AG callback param of ESP_HF_VTS_RESPONSE_EVT */
@ -174,7 +174,7 @@ typedef union
* @brief ESP_HF_NREC_RESPONSE_EVT
*/
struct hf_nrec_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_nrec_t state; /*!< NREC enabled or disabled */
} nrec; /*!< AG callback param of ESP_HF_NREC_RESPONSE_EVT */
@ -196,7 +196,7 @@ typedef union
* @brief ESP_HF_WBS_RESPONSE_EVT
*/
struct hf_wbs_rep_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_bd_addr_t remote_addr; /*!< 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 */
@ -204,7 +204,7 @@ typedef union
* @brief ESP_HF_BCS_RESPONSE_EVT
*/
struct hf_bcs_rep_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_bd_addr_t remote_addr; /*!< 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 */

View File

@ -1349,7 +1349,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memcpy(param.volume_control.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.volume_control.remote_addr, &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.volume = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_VOLUME_CONTROL_EVT, &param);
@ -1362,7 +1362,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memcpy(param.unat_rep.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.unat_rep.remote_addr, &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);
@ -1371,31 +1371,46 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_CBC_EVT:
{
btc_hf_cb_to_app(ESP_HF_IND_UPDATE_EVT, NULL);
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.ind_upd.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_IND_UPDATE_EVT, &param);
break;
}
case BTA_AG_AT_CIND_EVT:
{
btc_hf_cb_to_app(ESP_HF_CIND_RESPONSE_EVT, NULL);
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.cind_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CIND_RESPONSE_EVT, &param);
break;
}
case BTA_AG_AT_COPS_EVT:
{
btc_hf_cb_to_app(ESP_HF_COPS_RESPONSE_EVT, NULL);
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.cops_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_COPS_RESPONSE_EVT, &param);
break;
}
case BTA_AG_AT_CLCC_EVT:
{
btc_hf_cb_to_app(ESP_HF_CLCC_RESPONSE_EVT, NULL);
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.clcc_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CLCC_RESPONSE_EVT, &param);
break;
}
case BTA_AG_AT_CNUM_EVT:
{
btc_hf_cb_to_app(ESP_HF_CNUM_RESPONSE_EVT, NULL);
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.cnum_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CNUM_RESPONSE_EVT, &param);
break;
}
@ -1404,7 +1419,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memcpy(param.vts_rep.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.vts_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.vts_rep.code = p_data->val.str;
btc_hf_cb_to_app(ESP_HF_VTS_RESPONSE_EVT, &param);
} while(0);
@ -1416,7 +1431,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memcpy(param.nrec.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.nrec.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.nrec.state = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_NREC_RESPONSE_EVT, &param);
} while(0);
@ -1425,13 +1440,19 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_A_EVT:
{
btc_hf_cb_to_app(ESP_HF_ATA_RESPONSE_EVT, NULL);
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.ata_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_ATA_RESPONSE_EVT, &param);
break;
}
case BTA_AG_AT_CHUP_EVT:
{
btc_hf_cb_to_app(ESP_HF_CHUP_RESPONSE_EVT, NULL);
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.chup_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CHUP_RESPONSE_EVT, &param);
break;
}

View File

@ -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:
{
ESP_LOGI(BT_HF_TAG, "--UNKOW AT CMD: %s", param->unat_rep.unat);
esp_hf_ag_unknown_at_send(param->unat_rep.remote_bda, NULL);
esp_hf_ag_unknown_at_send(param->unat_rep.remote_addr, NULL);
break;
}