Component/bt: fix reconnect fail in smp

This commit is contained in:
zhiweijian 2018-03-16 18:25:03 +08:00
parent 0cb7b27f8b
commit d0e553358a
6 changed files with 72 additions and 21 deletions

View File

@ -829,7 +829,7 @@ tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
if ( p_clreg->notif_reg[i].in_use &&
!memcmp(p_clreg->notif_reg[i].remote_bda, bda, BD_ADDR_LEN) &&
p_clreg->notif_reg[i].handle == handle) {
APPL_TRACE_WARNING("notification already registered");
APPL_TRACE_DEBUG("notification already registered");
status = BTA_GATT_OK;
break;
}

View File

@ -180,11 +180,7 @@ BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, tBTM_LE_
#if (BLE_PRIVACY_SPT == TRUE)
if (key_type == BTM_LE_KEY_PID || key_type == BTM_LE_KEY_LID) {
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller.
* It is a design problem of hardware. The temporal solution is not to
* send the key to the controller and then resolve the random address in host. */
//btm_ble_resolving_list_load_dev (p_dev_rec);
btm_ble_resolving_list_load_dev (p_dev_rec);
}
#endif
@ -1916,7 +1912,17 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
/* possiblly receive connection complete with resolvable random on
slave role while the device has been paired */
if (!match && role == HCI_ROLE_SLAVE && BTM_BLE_IS_RESOLVE_BDA(bda)) {
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller.
* It is a design problem of hardware. The temporal solution is not to
* send the key to the controller and then resolve the random address in host.
* so we need send the real address information to controller to connect.
* Once the connection is successful, resolve device address whether it is
* slave or master*/
/* if (!match && role == HCI_ROLE_SLAVE && BTM_BLE_IS_RESOLVE_BDA(bda)) { */
if (!match && BTM_BLE_IS_RESOLVE_BDA(bda)) {
// save the enhanced value to used in btm_ble_resolve_random_addr_on_conn_cmpl func.
temp_enhanced = enhanced;
btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_conn_cmpl, p_data);
@ -2075,11 +2081,7 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data)
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
/* add all bonded device into resolving list if IRK is available*/
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller.
* It is a design problem of hardware. The temporal solution is not to
* send the key to the controller and then resolve the random address in host. */
//btm_ble_resolving_list_load_dev(p_dev_rec);
btm_ble_resolving_list_load_dev(p_dev_rec);
#endif
}

View File

@ -2984,6 +2984,8 @@ void btm_send_sel_conn_callback(BD_ADDR remote_bda, UINT8 evt_type, UINT8 *p_dat
void btm_ble_process_adv_pkt (UINT8 *p_data)
{
BD_ADDR bda;
BD_ADDR temp_bda;
UINT8 temp_addr_type = 0;
UINT8 evt_type = 0, *p = p_data;
UINT8 addr_type = 0;
UINT8 num_reports;
@ -3005,6 +3007,8 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
STREAM_TO_UINT8 (evt_type, p);
STREAM_TO_UINT8 (addr_type, p);
STREAM_TO_BDADDR (bda, p);
temp_addr_type = addr_type;
memcpy(temp_bda, bda, BD_ADDR_LEN);
//BTM_TRACE_ERROR("btm_ble_process_adv_pkt:bda= %0x:%0x:%0x:%0x:%0x:%0x\n",
// bda[0],bda[1],bda[2],bda[3],bda[4],bda[5]);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
@ -3019,7 +3023,13 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
} else
#endif
btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
//save current adv addr information if p_dev_rec!= NULL
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
if(p_dev_rec) {
p_dev_rec->ble.current_addr_type = temp_addr_type;
memcpy(p_dev_rec->ble.current_addr, temp_bda, BD_ADDR_LEN);
p_dev_rec->ble.current_addr_valid = true;
}
STREAM_TO_UINT8(data_len, p);
/* Advance to the next event data_len + rssi byte */

View File

@ -765,18 +765,22 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
btm_ble_update_resolving_list(p_dev_rec->bd_addr, TRUE);
if (controller_get_interface()->supports_ble_privacy()) {
BD_ADDR dummy_bda = {0};
UINT8 *peer_irk = p_dev_rec->ble.keys.irk;
UINT8 *local_irk = btm_cb.devcb.id_keys.irk;
if (memcmp(p_dev_rec->ble.static_addr, dummy_bda, BD_ADDR_LEN) == 0) {
memcpy(p_dev_rec->ble.static_addr, p_dev_rec->bd_addr, BD_ADDR_LEN);
p_dev_rec->ble.static_addr_type = p_dev_rec->ble.ble_addr_type;
}
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller.
* It is a design problem of hardware. The temporal solution is not to
* send the key to the controller and then resolve the random address in host. */
/*
BTM_TRACE_DEBUG("%s:adding device to controller resolving list\n", __func__);
// use identical IRK for now
UINT8 *peer_irk = p_dev_rec->ble.keys.irk;
UINT8 *local_irk = btm_cb.devcb.id_keys.irk;
//use identical IRK for now
rt = btsnd_hcic_ble_add_device_resolving_list(p_dev_rec->ble.static_addr_type,
p_dev_rec->ble.static_addr, peer_irk, local_irk);
*/
} else {
UINT8 param[40] = {0};
UINT8 *p = param;
@ -807,7 +811,7 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
}
}
} else {
BTM_TRACE_ERROR("Device already in Resolving list\n");
BTM_TRACE_DEBUG("Device already in Resolving list\n");
rt = TRUE;
}
} else {

View File

@ -486,6 +486,11 @@ typedef struct {
tBTM_LE_KEY_TYPE key_type; /* bit mask of valid key types in record */
tBTM_SEC_BLE_KEYS keys; /* LE device security info in slave rode */
#endif
#if (BLE_PRIVACY_SPT == TRUE)
tBLE_ADDR_TYPE current_addr_type; /* current adv addr type*/
BD_ADDR current_addr; /* current adv addr*/
bool current_addr_valid; /* current addr info is valid or not*/
#endif
} tBTM_SEC_BLE;

View File

@ -766,6 +766,15 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
*******************************************************************************/
BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
{
#if ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE))
//check for security device information in the cache
bool dev_rec_exist = true;
tBTM_SEC_DEV_REC *find_dev_rec = btm_find_dev (p_lcb->remote_bd_addr);
if(find_dev_rec == NULL) {
dev_rec_exist = false;
}
#endif
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_lcb->remote_bd_addr);
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
UINT16 scan_int;
@ -788,6 +797,26 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
#if ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE))
own_addr_type = btm_cb.ble_ctr_cb.privacy_mode ? BLE_ADDR_RANDOM : BLE_ADDR_PUBLIC;
if(dev_rec_exist) {
// if the current address information is valid, get the real address information
if(p_dev_rec->ble.current_addr_valid) {
peer_addr_type = p_dev_rec->ble.current_addr_type;
memcpy(peer_addr, p_dev_rec->ble.current_addr, 6);
} else {
/* find security device information but not find the real address information
* This state may be directly open whithout scanning. In this case, you must
* use the current adv address of the device to open*/
}
} else {
//not find security device information, We think this is a new device, connect directly
}
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller.
* It is a design problem of hardware. The temporal solution is not to
* send the key to the controller and then resolve the random address in host.
* so we need send the real address information to controller. */
/*
if (p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) {
if (btm_cb.ble_ctr_cb.privacy_mode >= BTM_PRIVACY_1_2) {
own_addr_type |= BLE_ADDR_TYPE_ID_BIT;
@ -798,6 +827,7 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
} else {
btm_ble_disable_resolving_list(BTM_BLE_RL_INIT, TRUE);
}
*/
#endif
if (!btm_ble_topology_check(BTM_BLE_STATE_INIT)) {