fix(bt/bluedroid): Added peer Bluetooth device address into HF callback parameters

This commit is contained in:
Jin Cheng 2023-08-23 19:30:40 +08:00
parent a93b6674c4
commit 6d301d11bc
3 changed files with 108 additions and 27 deletions

View File

@ -105,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 */
@ -113,8 +114,9 @@ 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 */
} unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */
/**
* @brief ESP_HF_DIAL_EVT
@ -125,24 +127,76 @@ typedef union
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 */
@ -150,6 +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_hf_wbs_config_t mode; /*!< codec mode CVSD or mSBC */
} bcs_rep; /*!< AG callback param of ESP_HF_BCS_RESPONSE_EVT */

View File

@ -1351,8 +1351,11 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_SPK_EVT:
case BTA_AG_MIC_EVT:
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
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.volume = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_VOLUME_CONTROL_EVT, &param);
@ -1362,9 +1365,14 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_UNAT_EVT:
{
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.unat_rep.unat = p_data->val.str;
btc_hf_cb_to_app(ESP_HF_UNAT_RESPONSE_EVT, &param);
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
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;
}
@ -1400,8 +1408,11 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_VTS_EVT:
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
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;
btc_hf_cb_to_app(ESP_HF_VTS_RESPONSE_EVT, &param);
} while(0);
@ -1410,8 +1421,11 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_NREC_EVT:
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
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;
btc_hf_cb_to_app(ESP_HF_NREC_RESPONSE_EVT, &param);
} while(0);
@ -1447,6 +1461,8 @@ void btc_hf_cb_handler(btc_msg_t *msg)
osi_free(param.out_call.num_or_loc);
} 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);
}
} while(0);
@ -1489,20 +1505,30 @@ void btc_hf_cb_handler(btc_msg_t *msg)
#if (BTM_WBS_INCLUDED == TRUE)
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);
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.wbs_rep.codec = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_WBS_RESPONSE_EVT, &param);
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
BTC_TRACE_DEBUG("Set codec status %d codec %d 1=CVSD 2=MSBC", p_data->val.hdr.status, p_data->val.num);
memset(&param, 0, sizeof(esp_hf_cb_param_t));
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;
}
case BTA_AG_AT_BCS_EVT:
{
BTC_TRACE_DEBUG("AG final seleded codec is %d 1=CVSD 2=MSBC", p_data->val.num);
memset(&param, 0, sizeof(esp_hf_cb_param_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);
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
BTC_TRACE_DEBUG("AG final seleded codec is %d 1=CVSD 2=MSBC", p_data->val.num);
memset(&param, 0, sizeof(esp_hf_cb_param_t));
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;
}
#endif

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(hf_peer_addr, NULL);
esp_hf_ag_unknown_at_send(param->unat_rep.remote_bda, NULL);
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_network_state_t ntk_state = 1;
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;
}
@ -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;
int batt_lev = 3;
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;
}
case ESP_HF_COPS_RESPONSE_EVT:
{
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;
}
@ -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_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;
}
@ -406,7 +406,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
char *number = {"123456"};
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_hf_ag_cnum_response(hf_peer_addr, number,type);
esp_hf_ag_cnum_response(param->cnum_rep.remote_addr, number,type);
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.");
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;
}
@ -434,7 +434,7 @@ 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.");
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;
}
@ -444,7 +444,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
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_hf_ag_out_call(hf_peer_addr,1,0,1,0,param->out_call.num_or_loc,0);
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);
@ -452,10 +452,10 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
bool num_found = true;
if (num_found) {
char *number = "123456";
esp_hf_ag_cmee_send(hf_peer_addr, ESP_HF_AT_RESPONSE_CODE_OK, ESP_HF_CME_AG_FAILURE);
esp_hf_ag_out_call(hf_peer_addr,1,0,1,0,number,0);
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(hf_peer_addr, ESP_HF_AT_RESPONSE_CODE_CME, ESP_HF_CME_MEMORY_FAILURE);
esp_hf_ag_cmee_send(param->out_call.remote_addr, ESP_HF_AT_RESPONSE_CODE_CME, ESP_HF_CME_MEMORY_FAILURE);
}
}
} else {