01_SDK/nimble/host/nimble/nimble/host/src/ble_store_util.c
@@ -96,6 +96,40 @@
    return 0;
}
#if SMP_MULTI_ADDR_MODE_EN
int
ble_store_util_delete_peer(const ble_addr_t *peer_id_addr, const ble_addr_t *own_id_addr)
{
   union ble_store_key key;
    int rc = 0;
    memset(&key, 0, sizeof key);
    key.sec.peer_addr = *peer_id_addr;
    key.sec.own_addr  = *own_id_addr;
    key.sec.is_own_addr_valid = 0xAA;
    rc = ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_OUR_SEC, &key);
    if (rc != 0) {
        return rc;
    }
    rc = ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_PEER_SEC, &key);
    if (rc != 0) {
        return rc;
    }
   key.cccd.is_own_addr_valid = 0xAA;
   key.cccd.chr_val_handle = 0;
    rc = ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_CCCD, &key);
    if (rc != 0) {
        return rc;
    }
    return 0;
}
#else
/**
 * Deletes all entries from the store that are attached to the specified peer
 * address.  This function deletes security entries and CCCD records.
@@ -134,6 +168,7 @@
    return 0;
}
#endif
/**
 * Deletes all entries from the store that match the specified key.
@@ -189,6 +224,27 @@
    return 0;
}
#if SMP_MULTI_ADDR_MODE_EN
int
ble_store_util_delete_oldest_peer(void)
{
    int num_peers;
    int rc;
    num_peers = ble_store_config_get_our_secs_num();
    if(num_peers == 0){
        return 0;
    }
    struct ble_store_value_sec *oldest_val_sec = ble_store_config_get_our_secs(0);
    rc = ble_store_util_delete_peer(&oldest_val_sec->peer_addr, &oldest_val_sec->own_addr);
    if (rc != 0) {
        return rc;
    }
    return 0;
}
#else
int
ble_store_util_delete_oldest_peer(void)
{
@@ -214,6 +270,7 @@
    return 0;
}
#endif
/**
 * Round-robin status callback.  If a there is insufficient storage capacity