From e3d3ed5a0632ee56ac891340884abd48634da37c Mon Sep 17 00:00:00 2001 From: Tian Hao Date: Thu, 21 Jun 2018 21:43:46 +0800 Subject: [PATCH] bt : fix read rssi conflict when in dual mode --- components/bt/bluedroid/bta/dm/bta_dm_act.c | 8 ++++---- components/bt/bluedroid/bta/dm/bta_dm_api.c | 3 ++- .../bt/bluedroid/bta/dm/include/bta_dm_int.h | 1 + components/bt/bluedroid/bta/include/bta/bta_api.h | 2 +- .../bluedroid/btc/profile/std/gap/btc_gap_ble.c | 2 +- .../bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c | 2 +- components/bt/bluedroid/stack/btm/btm_acl.c | 15 ++------------- .../bt/bluedroid/stack/include/stack/btm_api.h | 6 +++--- 8 files changed, 15 insertions(+), 24 deletions(-) diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index 5e84d7daa0..5cdba14b47 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -602,16 +602,16 @@ void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data) if (p_data->read_tx_power.read_tx_power_cb != NULL) { BTM_BleReadAdvTxPower(p_data->read_tx_power.read_tx_power_cb); } else { - APPL_TRACE_ERROR("%s(), the callback function cann't be NULL.", __func__); + APPL_TRACE_ERROR("%s(), the callback function can't be NULL.", __func__); } } void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data) { if (p_data->rssi.read_rssi_cb != NULL) { - BTM_ReadRSSI(p_data->rssi.remote_addr, p_data->rssi.read_rssi_cb); + BTM_ReadRSSI(p_data->rssi.remote_addr, p_data->rssi.transport, p_data->rssi.read_rssi_cb); } else { - APPL_TRACE_ERROR("%s(), the callback function cann't be NULL.", __func__); + APPL_TRACE_ERROR("%s(), the callback function can't be NULL.", __func__); } } @@ -4665,7 +4665,7 @@ void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data) void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data) { if (p_data->hdr.event != BTA_DM_API_BLE_STOP_ADV_EVT) { - APPL_TRACE_ERROR("Invalid BTA event,cann't stop the BLE adverting\n"); + APPL_TRACE_ERROR("Invalid BTA event,can't stop the BLE adverting\n"); } btm_ble_stop_adv(); diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index 1f2262ae90..6d0538f04d 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -206,12 +206,13 @@ void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb) } } -void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_CMPL_CB *cmpl_cb) +void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb) { tBTA_DM_API_READ_RSSI *p_msg; if ((p_msg = (tBTA_DM_API_READ_RSSI *)osi_malloc(sizeof(tBTA_DM_API_READ_RSSI))) != NULL) { p_msg->hdr.event = BTA_DM_API_BLE_READ_RSSI_EVT; memcpy(p_msg->remote_addr, remote_addr, sizeof(BD_ADDR)); + p_msg->transport = transport; p_msg->read_rssi_cb = cmpl_cb; bta_sys_sendmsg(p_msg); } diff --git a/components/bt/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/bluedroid/bta/dm/include/bta_dm_int.h index 8ee1dda61b..6a41f52dec 100644 --- a/components/bt/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/bluedroid/bta/dm/include/bta_dm_int.h @@ -196,6 +196,7 @@ typedef struct { typedef struct { BT_HDR hdr; BD_ADDR remote_addr; + tBTA_TRANSPORT transport; tBTA_CMPL_CB *read_rssi_cb; }tBTA_DM_API_READ_RSSI; diff --git a/components/bt/bluedroid/bta/include/bta/bta_api.h b/components/bt/bluedroid/bta/include/bta/bta_api.h index 702701bd2e..c8903bfdd3 100644 --- a/components/bt/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/bluedroid/bta/include/bta/bta_api.h @@ -1428,7 +1428,7 @@ extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBTA extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb); -extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_CMPL_CB *cmpl_cb); +extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb); /******************************************************************************* ** diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c index c3937cf652..1cb321fe0f 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -1018,7 +1018,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, btc_add_whitelist_complete_callback); break; case BTC_GAP_BLE_ACT_READ_RSSI: - BTA_DmBleReadRSSI(arg->read_rssi.remote_addr, btc_read_ble_rssi_cmpl_callback); + BTA_DmBleReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback); break; case BTC_GAP_BLE_ACT_SET_CONN_PARAMS: BTA_DmSetBlePrefConnParams(arg->set_conn_params.bd_addr, arg->set_conn_params.min_conn_int, diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c index c6a5a0894a..a28cd2b722 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c @@ -632,7 +632,7 @@ static void btc_gap_bt_read_rssi_delta_cmpl_callback(void *p_data) static void btc_gap_bt_read_rssi_delta(btc_gap_bt_args_t *arg) { - BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, btc_gap_bt_read_rssi_delta_cmpl_callback); + BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback); } esp_err_t btc_gap_bt_remove_bond_device(btc_gap_bt_args_t *arg) diff --git a/components/bt/bluedroid/stack/btm/btm_acl.c b/components/bt/bluedroid/stack/btm/btm_acl.c index 84fa0d6b71..5bf59c895c 100644 --- a/components/bt/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/bluedroid/stack/btm/btm_acl.c @@ -1905,14 +1905,10 @@ void btm_qos_setup_complete (UINT8 status, UINT16 handle, FLOW_SPEC *p_flow) ** Returns BTM_CMD_STARTED if successfully initiated or error code ** *******************************************************************************/ -tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb) +tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb) { tACL_CONN *p; - tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR; -#if BLE_INCLUDED == TRUE - tBT_DEVICE_TYPE dev_type; - tBLE_ADDR_TYPE addr_type; -#endif + BTM_TRACE_API ("BTM_ReadRSSI: RemBdAddr: %02x%02x%02x%02x%02x%02x\n", remote_bda[0], remote_bda[1], remote_bda[2], remote_bda[3], remote_bda[4], remote_bda[5]); @@ -1924,13 +1920,6 @@ tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb) return (BTM_BUSY); } -#if BLE_INCLUDED == TRUE - BTM_ReadDevInfo(remote_bda, &dev_type, &addr_type); - if (dev_type == BT_DEVICE_TYPE_BLE) { - transport = BT_TRANSPORT_LE; - } -#endif - p = btm_bda_to_acl(remote_bda, transport); if (p != (tACL_CONN *)NULL) { btu_start_timer (&btm_cb.devcb.rssi_timer, BTU_TTYPE_BTM_ACL, diff --git a/components/bt/bluedroid/stack/include/stack/btm_api.h b/components/bt/bluedroid/stack/include/stack/btm_api.h index 79ecba8c8f..067878a8e1 100644 --- a/components/bt/bluedroid/stack/include/stack/btm_api.h +++ b/components/bt/bluedroid/stack/include/stack/btm_api.h @@ -2811,8 +2811,8 @@ tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr, ** ** Function BTM_ReadRSSI ** -** Description This function is called to read the link policy settings. -** The address of link policy results are returned in the callback. +** Description This function is called to read the RSSI for a particular transport. +** The RSSI of results are returned in the callback. ** (tBTM_RSSI_RESULTS) ** ** Returns BTM_CMD_STARTED if command issued to controller. @@ -2822,7 +2822,7 @@ tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr, ** *******************************************************************************/ //extern -tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb); +tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb); /*******************************************************************************