BTA_GATTC_CancelOpen(0, bd_addr, FALSE);
#endif
- BTM_SecDeleteDevice(bd_addr);
+ BTM_SecDeleteDevice(bd_addr, transport);
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* remove all cached GATT information */
/* Take the link down first, and mark the device for removal when disconnected */
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
- if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, p_dev->bd_addr)) {
+ if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, p_dev->bd_addr)
+ && bta_dm_cb.device_list.peer_device[i].transport == transport) {
bta_dm_cb.device_list.peer_device[i].conn_state = BTA_DM_UNPAIRING;
btm_remove_acl( p_dev->bd_addr, bta_dm_cb.device_list.peer_device[i].transport);
APPL_TRACE_DEBUG("%s:transport = %d", __func__,
}
/* if to remove the device from security database ? do it now */
else if (p_remove_acl->remove_dev) {
- if (!BTM_SecDeleteDevice(p_remove_acl->bd_addr)) {
+ if (!BTM_SecDeleteDevice(p_remove_acl->bd_addr, p_remove_acl->transport)) {
APPL_TRACE_ERROR("delete device from security database failed.");
}
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
}
if ( bta_dm_cb.device_list.peer_device[i].conn_state == BTA_DM_UNPAIRING ) {
- if (BTM_SecDeleteDevice(bta_dm_cb.device_list.peer_device[i].peer_bdaddr)) {
+ if (BTM_SecDeleteDevice(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, bta_dm_cb.device_list.peer_device[i].transport)) {
issue_unpair_cb = TRUE;
}
}
}
if (conn.link_down.is_removed) {
- BTM_SecDeleteDevice(p_bda);
+ BTM_SecDeleteDevice(p_bda, p_data->acl_change.transport);
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* need to remove all pending background connection */
BTA_GATTC_CancelOpen(0, p_bda, FALSE);
APPL_TRACE_ERROR(" %s Device does not exist in DB", __FUNCTION__);
}
} else {
- BTM_SecDeleteDevice (remote_bd_addr);
+ BTM_SecDeleteDevice (remote_bd_addr, bta_dm_cb.device_list.peer_device[index].transport);
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* need to remove all pending background connection */
BTA_GATTC_CancelOpen(0, remote_bd_addr, FALSE);
** Description Free resources associated with the device.
**
** Parameters: bd_addr - BD address of the peer
+** transport - BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE
**
** Returns TRUE if removed OK, FALSE if not found or ACL link is active
**
*******************************************************************************/
-BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr)
+BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr, tBT_TRANSPORT transport)
{
+
tBTM_SEC_DEV_REC *p_dev_rec;
- if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE) ||
- BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_BR_EDR)) {
+ if (BTM_IsAclConnectionUp(bd_addr, transport)) {
BTM_TRACE_WARNING("%s FAILED: Cannot Delete when connection is active\n", __func__);
return FALSE;
}
-
if ((p_dev_rec = btm_find_dev(bd_addr)) != NULL) {
- btm_sec_free_dev(p_dev_rec);
+ btm_sec_free_dev(p_dev_rec, transport);
+
/* Tell controller to get rid of the link key, if it has one stored */
BTM_DeleteStoredLinkKey (p_dev_rec->bd_addr, NULL);
}
** Description Mark device record as not used
**
*******************************************************************************/
-void btm_sec_free_dev (tBTM_SEC_DEV_REC *p_dev_rec)
+void btm_sec_free_dev (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport)
{
- p_dev_rec->bond_type = BOND_TYPE_UNKNOWN;
- p_dev_rec->sec_flags = 0;
-
+ if (transport == BT_TRANSPORT_BR_EDR) {
+ memset(p_dev_rec->link_key, 0, LINK_KEY_LEN);
+ p_dev_rec->sec_flags &= ~(BTM_SEC_AUTHORIZED | BTM_SEC_AUTHENTICATED
+ | BTM_SEC_ENCRYPTED | BTM_SEC_NAME_KNOWN
+ | BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_LINK_KEY_AUTHED
+ | BTM_SEC_ROLE_SWITCHED | BTM_SEC_16_DIGIT_PIN_AUTHED);
+ } else if (transport == BT_TRANSPORT_LE) {
+ p_dev_rec->bond_type = BOND_TYPE_UNKNOWN;
+ p_dev_rec->sec_flags &= ~(BTM_SEC_LE_AUTHENTICATED | BTM_SEC_LE_ENCRYPTED
+ | BTM_SEC_LE_NAME_KNOWN | BTM_SEC_LE_LINK_KEY_KNOWN
+ | BTM_SEC_LE_LINK_KEY_AUTHED | BTM_SEC_ROLE_SWITCHED);
#if BLE_INCLUDED == TRUE
- /* Clear out any saved BLE keys */
- btm_sec_clear_ble_keys (p_dev_rec);
+ /* Clear out any saved BLE keys */
+ btm_sec_clear_ble_keys (p_dev_rec);
#endif
+ } else {
+ p_dev_rec->bond_type = BOND_TYPE_UNKNOWN;
+ memset(p_dev_rec->link_key, 0, LINK_KEY_LEN);
+ p_dev_rec->sec_flags = 0;
-
+#if BLE_INCLUDED == TRUE
+ /* Clear out any saved BLE keys */
+ btm_sec_clear_ble_keys (p_dev_rec);
+#endif
+ }
}
/*******************************************************************************
bool skip_update_conn_param; /* skip update connection paraams or not*/
#endif
#if (BLE_PRIVACY_SPT == TRUE)
- tBLE_ADDR_TYPE current_addr_type; /* current adv addr type*/
+ 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
+#endif
} tBTM_SEC_BLE;
BOOLEAN btm_dev_support_switch (BD_ADDR bd_addr);
tBTM_SEC_DEV_REC *btm_sec_alloc_dev (BD_ADDR bd_addr);
-void btm_sec_free_dev (tBTM_SEC_DEV_REC *p_dev_rec);
+void btm_sec_free_dev (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport);
tBTM_SEC_DEV_REC *btm_find_dev (BD_ADDR bd_addr);
tBTM_SEC_DEV_REC *btm_find_or_alloc_dev (BD_ADDR bd_addr);
tBTM_SEC_DEV_REC *btm_find_dev_by_handle (UINT16 handle);
**
*******************************************************************************/
//extern
-BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr);
-
+BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr, tBT_TRANSPORT transport);
/*******************************************************************************
**