From e0f96eea2c19d96b0321e9030f04c38b6e2f2ed3 Mon Sep 17 00:00:00 2001 From: Prasad Alatkar Date: Wed, 24 Jul 2019 18:36:19 +0800 Subject: [PATCH] NimBLE: Fix bug in `get_nvs_db_attribute` related to delete bond in NVS --- nimble/host/store/config/src/ble_store_nvs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nimble/host/store/config/src/ble_store_nvs.c b/nimble/host/store/config/src/ble_store_nvs.c index c57c992f0..c19c0be89 100644 --- a/nimble/host/store/config/src/ble_store_nvs.c +++ b/nimble/host/store/config/src/ble_store_nvs.c @@ -376,7 +376,7 @@ int ble_store_config_persist_cccds() return ble_store_nvs_write(BLE_STORE_OBJ_TYPE_CCCD, &val); } else if (nvs_count > ble_store_config_num_cccds) { /* NVS db count more than RAM count, delete operation */ - nvs_idx = get_nvs_db_attribute(BLE_STORE_OBJ_TYPE_CCCD, -1, + nvs_idx = get_nvs_db_attribute(BLE_STORE_OBJ_TYPE_CCCD, 0, ble_store_config_cccds, ble_store_config_num_cccds); if (nvs_idx == -1) { ESP_LOGE(TAG, "NVS delete operation failed for CCCD"); @@ -402,7 +402,7 @@ int ble_store_config_persist_peer_secs() return ble_store_nvs_write(BLE_STORE_OBJ_TYPE_PEER_SEC, &val); } else if (nvs_count > ble_store_config_num_peer_secs) { /* NVS db count more than RAM count, delete operation */ - nvs_idx = get_nvs_db_attribute(BLE_STORE_OBJ_TYPE_PEER_SEC, -1, + nvs_idx = get_nvs_db_attribute(BLE_STORE_OBJ_TYPE_PEER_SEC, 0, ble_store_config_peer_secs, ble_store_config_num_peer_secs); if (nvs_idx == -1) { ESP_LOGE(TAG, "NVS delete operation failed for peer sec"); @@ -428,7 +428,7 @@ int ble_store_config_persist_our_secs() return ble_store_nvs_write(BLE_STORE_OBJ_TYPE_OUR_SEC, &val); } else if (nvs_count > ble_store_config_num_our_secs) { /* NVS db count more than RAM count, delete operation */ - nvs_idx = get_nvs_db_attribute(BLE_STORE_OBJ_TYPE_OUR_SEC, -1, + nvs_idx = get_nvs_db_attribute(BLE_STORE_OBJ_TYPE_OUR_SEC, 0, ble_store_config_our_secs, ble_store_config_num_our_secs); if (nvs_idx == -1) { ESP_LOGE(TAG, "NVS delete operation failed for our sec");