diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index 0f1b7568e..366ae9336 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -646,12 +646,7 @@ void bta_dm_process_remove_device(BD_ADDR bd_addr) if (bta_dm_cb.p_sec_cback) { tBTA_DM_SEC sec_event; bdcpy(sec_event.link_down.bd_addr, bd_addr); - if (btm_find_dev(bd_addr) != NULL) { - /* No connection, set status to success (acl disc code not valid) */ - sec_event.link_down.status = HCI_SUCCESS; - } else { - sec_event.link_down.status = HCI_ERR_ILLEGAL_COMMAND; - } + sec_event.link_down.status = HCI_SUCCESS; bta_dm_cb.p_sec_cback(BTA_DM_DEV_UNPAIRED_EVT, &sec_event); } } diff --git a/components/bt/bluedroid/btc/core/btc_dm.c b/components/bt/bluedroid/btc/core/btc_dm.c index a0bc44ec3..b81d5bc7b 100644 --- a/components/bt/bluedroid/btc/core/btc_dm.c +++ b/components/bt/bluedroid/btc/core/btc_dm.c @@ -467,12 +467,15 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) LOG_ERROR("BTA_DM_DEV_UNPAIRED_EVT"); memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR)); btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN); - //remove the bonded key in the config and nvs flash. - btc_storage_remove_ble_dev_type(&bd_addr, false); - btc_storage_remove_remote_addr_type(&bd_addr, false); - btc_storage_remove_ble_bonding_keys(&bd_addr); + param.remove_bond_dev_cmpl.status = ESP_BT_STATUS_FAIL; + + if (p_data->link_down.status == HCI_SUCCESS) { + //remove the bonded key in the config and nvs flash. + btc_storage_remove_ble_dev_type(&bd_addr, false); + btc_storage_remove_remote_addr_type(&bd_addr, false); + param.remove_bond_dev_cmpl.status = btc_storage_remove_ble_bonding_keys(&bd_addr); + } ble_msg.act = ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT; - param.remove_bond_dev_cmpl.status = (p_data->link_down.status == HCI_SUCCESS) ? ESP_BT_STATUS_SUCCESS : ESP_BT_STATUS_FAIL; memcpy(param.remove_bond_dev_cmpl.bd_addr, p_data->link_down.bd_addr, sizeof(BD_ADDR)); #endif /* #if (SMP_INCLUDED == TRUE) */ break;