]> granicus.if.org Git - esp-idf/commitdiff
nvs: Append _t to nvs_handle & nvs_open_mode types
authorGOPTIONS\pfrost <peter.frost@geotogether.com>
Mon, 1 Apr 2019 14:13:55 +0000 (15:13 +0100)
committerbot <bot@espressif.com>
Wed, 22 May 2019 02:53:28 +0000 (02:53 +0000)
Merges https://github.com/espressif/esp-idf/pull/3239/

13 files changed:
components/app_update/test/test_switch_ota.c
components/bt/bluedroid/bta/gatt/bta_gattc_co.c
components/bt/bluedroid/osi/config.c
components/esp_wifi/src/phy_init.c
components/lwip/port/esp32/netif/dhcp_state.c
components/nvs_flash/include/nvs.h
components/nvs_flash/src/nvs_api.cpp
components/nvs_flash/test/test_nvs.c
components/nvs_flash/test_nvs_host/test_nvs.cpp
examples/storage/nvs_rw_blob/main/nvs_blob_example_main.c
examples/storage/nvs_rw_value/main/nvs_value_example_main.c
examples/system/console/components/cmd_nvs/cmd_nvs.c
examples/system/ulp/main/ulp_example_main.c

index 0c0b0e75e5dca2442b5d282a329d7bd4111e3c26..d8cb2d62181233b72b679c9a1573a17bf42debd7 100644 (file)
@@ -387,7 +387,7 @@ static void test_flow4(void)
     boot_count++;
     ESP_LOGI(TAG, "boot count %d", boot_count);
     const esp_partition_t *cur_app = get_running_firmware();
-    nvs_handle handle = 0;
+    nvs_handle_t handle = 0;
     int boot_count_nvs = 0;
     switch (boot_count) {
         case 2:
index 37befab8051b069d6ede470e24065211c440ce5a..c11fb958959c04354b4586f31b4103f11304edac 100644 (file)
@@ -77,11 +77,11 @@ static void cacheReset(BD_ADDR bda)
 
 static const char *cache_key = "gattc_cache_key";
 static const char *cache_addr = "cache_addr_tab";
-nvs_handle nvs_fp;
+nvs_handle_t nvs_fp;
 
 typedef struct {
     //save the service data in the list according to the address
-    nvs_handle cache_fp;
+    nvs_handle_t cache_fp;
     BOOLEAN is_open;
     BD_ADDR addr;
     hash_key_t hash_key;
@@ -90,7 +90,7 @@ typedef struct {
 
 typedef struct {
     //save the address list in the cache
-    nvs_handle addr_fp;
+    nvs_handle_t addr_fp;
     BOOLEAN is_open;
     UINT8 num_addr;
     cache_addr_info_t cache_addr[MAX_DEVICE_IN_CACHE];
@@ -377,7 +377,7 @@ void bta_gattc_co_cache_reset(BD_ADDR server_bda)
 
 void bta_gattc_co_cache_addr_init(void)
 {
-    nvs_handle fp;
+    nvs_handle_t fp;
     esp_err_t err_code;
     UINT8 num_addr;
     UINT8 *p_buf = osi_malloc(MAX_ADDR_LIST_CACHE_BUF);
@@ -520,7 +520,7 @@ void bta_gattc_co_cache_addr_save(BD_ADDR bd_addr, hash_key_t hash_key)
         memcpy(cache_env.cache_addr[num - 1].hash_key, hash_key, sizeof(hash_key_t));
     }
 
-    nvs_handle *fp = &cache_env.addr_fp;
+    nvs_handle_t *fp = &cache_env.addr_fp;
     UINT16 length = num*(sizeof(BD_ADDR) + sizeof(hash_key_t));
 
     for (UINT8 i = 0; i < num; i++) {
index 55a3b3d4b02c3b364062dfbf275661bf62525eb4..9e60f5c107b17f0f620b445dc4876560b2bf3463 100644 (file)
@@ -48,7 +48,7 @@ struct config_t {
 // Empty definition; this type is aliased to list_node_t.
 struct config_section_iter_t {};
 
-static void config_parse(nvs_handle fp, config_t *config);
+static void config_parse(nvs_handle_t fp, config_t *config);
 
 static section_t *section_new(const char *name);
 static void section_free(void *ptr);
@@ -89,7 +89,7 @@ config_t *config_new(const char *filename)
     }
 
     esp_err_t err;
-    nvs_handle fp;
+    nvs_handle_t fp;
     err = nvs_open(filename, NVS_READWRITE, &fp);
     if (err != ESP_OK) {
         if (err == ESP_ERR_NVS_NOT_INITIALIZED) {
@@ -331,7 +331,7 @@ static int get_config_size(const config_t *config)
     return total_size;
 }
 
-static int get_config_size_from_flash(nvs_handle fp)
+static int get_config_size_from_flash(nvs_handle_t fp)
 {
     assert(fp != 0);
 
@@ -384,7 +384,7 @@ bool config_save(const config_t *config, const char *filename)
 
     esp_err_t err;
     int err_code = 0;
-    nvs_handle fp;
+    nvs_handle_t fp;
     char *line = osi_calloc(1024);
     const size_t keyname_bufsz = sizeof(CONFIG_KEY) + 5 + 1; // including log10(sizeof(i))
     char *keyname = osi_calloc(keyname_bufsz);
@@ -507,7 +507,7 @@ static char *trim(char *str)
     return str;
 }
 
-static void config_parse(nvs_handle fp, config_t *config)
+static void config_parse(nvs_handle_t fp, config_t *config)
 {
     assert(fp != 0);
     assert(config != NULL);
index 2fade4e35ce3033a0d61da04991ae8f27afee4e4..1490356f338d2390bdf66229b62c410034cdba95 100644 (file)
@@ -436,15 +436,15 @@ static const char* PHY_CAL_VERSION_KEY = "cal_version";
 static const char* PHY_CAL_MAC_KEY = "cal_mac";
 static const char* PHY_CAL_DATA_KEY = "cal_data";
 
-static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
+static esp_err_t load_cal_data_from_nvs_handle(nvs_handle_t handle,
         esp_phy_calibration_data_t* out_cal_data);
 
-static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
+static esp_err_t store_cal_data_to_nvs_handle(nvs_handle_t handle,
         const esp_phy_calibration_data_t* cal_data);
 
 esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_data)
 {
-    nvs_handle handle;
+    nvs_handle_t handle;
     esp_err_t err = nvs_open(PHY_NAMESPACE, NVS_READONLY, &handle);
     if (err == ESP_ERR_NVS_NOT_INITIALIZED) {
         ESP_LOGE(TAG, "%s: NVS has not been initialized. "
@@ -461,7 +461,7 @@ esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_dat
 
 esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_data)
 {
-    nvs_handle handle;
+    nvs_handle_t handle;
     esp_err_t err = nvs_open(PHY_NAMESPACE, NVS_READWRITE, &handle);
     if (err != ESP_OK) {
         ESP_LOGD(TAG, "%s: failed to open NVS namespace (0x%x)", __func__, err);
@@ -476,7 +476,7 @@ esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_da
 
 esp_err_t esp_phy_erase_cal_data_in_nvs(void)
 {
-    nvs_handle handle;
+    nvs_handle_t handle;
     esp_err_t err = nvs_open(PHY_NAMESPACE, NVS_READWRITE, &handle);
     if (err != ESP_OK) {
         ESP_LOGE(TAG, "%s: failed to open NVS phy namespace (0x%x)", __func__, err);
@@ -498,7 +498,7 @@ esp_err_t esp_phy_erase_cal_data_in_nvs(void)
     return err;
 }
 
-static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
+static esp_err_t load_cal_data_from_nvs_handle(nvs_handle_t handle,
         esp_phy_calibration_data_t* out_cal_data)
 {
     esp_err_t err;
@@ -547,7 +547,7 @@ static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
     return ESP_OK;
 }
 
-static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
+static esp_err_t store_cal_data_to_nvs_handle(nvs_handle_t handle,
         const esp_phy_calibration_data_t* cal_data)
 {
     esp_err_t err;
index 9301ff3b0c6970d6bd855428bbb821b17414944c..ede094bd4f34c8a68296455abe79bae00afa4d68 100644 (file)
@@ -33,7 +33,7 @@ _Static_assert(sizeof(interface_key) / sizeof(char*) == TCPIP_ADAPTER_IF_MAX,
 
 bool dhcp_ip_addr_restore(void *netif)
 {
-    nvs_handle nvs;
+    nvs_handle_t nvs;
     bool err = false;
     struct netif *net = (struct netif *)netif;
     struct dhcp *dhcp = netif_dhcp_data(net);
@@ -54,7 +54,7 @@ bool dhcp_ip_addr_restore(void *netif)
 
 void dhcp_ip_addr_store(void *netif)
 {
-    nvs_handle nvs;
+    nvs_handle_t nvs;
     struct netif *net = (struct netif *)netif;
     struct dhcp *dhcp = netif_dhcp_data(net);
     uint32_t ip_addr = dhcp->offered_ip_addr.addr;
@@ -73,7 +73,7 @@ void dhcp_ip_addr_store(void *netif)
 
 void dhcp_ip_addr_erase(void *netif)
 {
-    nvs_handle nvs;
+    nvs_handle_t nvs;
     struct netif *net = (struct netif *)netif;
     esp_interface_t netif_id = tcpip_adapter_get_esp_if(net);
 
index 4fe4408609fc408e7eb65dee9586f9817c923270..13f5b9552a9b8bc71adbebc4354f680bc31d15b0 100644 (file)
@@ -26,7 +26,12 @@ extern "C" {
 /**
  * Opaque pointer type representing non-volatile storage handle
  */
-typedef uint32_t nvs_handle;
+typedef uint32_t nvs_handle_t;
+
+/*
+ * Pre-IDF V4.0 uses nvs_handle, so leaving the original typedef here for compatibility.
+ */
+typedef nvs_handle_t nvs_handle;
 
 #define ESP_ERR_NVS_BASE                    0x1100                     /*!< Starting number of error codes */
 #define ESP_ERR_NVS_NOT_INITIALIZED         (ESP_ERR_NVS_BASE + 0x01)  /*!< The storage driver is not initialized */
@@ -57,14 +62,19 @@ typedef uint32_t nvs_handle;
 #define ESP_ERR_NVS_CONTENT_DIFFERS         (ESP_ERR_NVS_BASE + 0x18)  /*!< Internal error; never returned by nvs API functions.  NVS key is different in comparison */
 
 #define NVS_DEFAULT_PART_NAME           "nvs"   /*!< Default partition name of the NVS partition in the partition table */
+
 /**
  * @brief Mode of opening the non-volatile storage
- *
  */
 typedef enum {
        NVS_READONLY,  /*!< Read only */
        NVS_READWRITE  /*!< Read and write */
-} nvs_open_mode;
+} nvs_open_mode_t;
+
+/*
+ * Pre-IDF V4.0 uses nvs_open_mode, so leaving the original typedef here for compatibility.
+ */
+typedef nvs_open_mode_t nvs_open_mode
 
 typedef enum {
     NVS_TYPE_U8    = 0x01,
@@ -107,7 +117,7 @@ typedef enum {
  *             - ESP_ERR_NVS_INVALID_NAME if namespace name doesn't satisfy constraints
  *             - other error codes from the underlying storage driver
  */
-esp_err_t nvs_open(const char* name, nvs_open_mode open_mode, nvs_handle *out_handle);
+esp_err_t nvs_open(const char* name, nvs_open_mode_t open_mode, nvs_handle_t *out_handle);
 
 /**
  * @brief      Open non-volatile storage with a given namespace from specified partition
@@ -135,7 +145,7 @@ esp_err_t nvs_open(const char* name, nvs_open_mode open_mode, nvs_handle *out_ha
  *             - ESP_ERR_NVS_INVALID_NAME if namespace name doesn't satisfy constraints
  *             - other error codes from the underlying storage driver
  */
-esp_err_t nvs_open_from_partition(const char *part_name, const char* name, nvs_open_mode open_mode, nvs_handle *out_handle);
+esp_err_t nvs_open_from_partition(const char *part_name, const char* name, nvs_open_mode_t open_mode, nvs_handle_t *out_handle);
 
 /**@{*/
 /**
@@ -166,15 +176,15 @@ esp_err_t nvs_open_from_partition(const char *part_name, const char* name, nvs_o
  *               flash operation doesn't fail again.
  *             - ESP_ERR_NVS_VALUE_TOO_LONG if the string value is too long
  */
-esp_err_t nvs_set_i8  (nvs_handle handle, const char* key, int8_t value);
-esp_err_t nvs_set_u8  (nvs_handle handle, const char* key, uint8_t value);
-esp_err_t nvs_set_i16 (nvs_handle handle, const char* key, int16_t value);
-esp_err_t nvs_set_u16 (nvs_handle handle, const char* key, uint16_t value);
-esp_err_t nvs_set_i32 (nvs_handle handle, const char* key, int32_t value);
-esp_err_t nvs_set_u32 (nvs_handle handle, const char* key, uint32_t value);
-esp_err_t nvs_set_i64 (nvs_handle handle, const char* key, int64_t value);
-esp_err_t nvs_set_u64 (nvs_handle handle, const char* key, uint64_t value);
-esp_err_t nvs_set_str (nvs_handle handle, const char* key, const char* value);
+esp_err_t nvs_set_i8  (nvs_handle_t handle, const char* key, int8_t value);
+esp_err_t nvs_set_u8  (nvs_handle_t handle, const char* key, uint8_t value);
+esp_err_t nvs_set_i16 (nvs_handle_t handle, const char* key, int16_t value);
+esp_err_t nvs_set_u16 (nvs_handle_t handle, const char* key, uint16_t value);
+esp_err_t nvs_set_i32 (nvs_handle_t handle, const char* key, int32_t value);
+esp_err_t nvs_set_u32 (nvs_handle_t handle, const char* key, uint32_t value);
+esp_err_t nvs_set_i64 (nvs_handle_t handle, const char* key, int64_t value);
+esp_err_t nvs_set_u64 (nvs_handle_t handle, const char* key, uint64_t value);
+esp_err_t nvs_set_str (nvs_handle_t handle, const char* key, const char* value);
 /**@}*/ 
 
 /**
@@ -204,7 +214,7 @@ esp_err_t nvs_set_str (nvs_handle handle, const char* key, const char* value);
  *               flash operation doesn't fail again.
  *             - ESP_ERR_NVS_VALUE_TOO_LONG if the value is too long
  */
-esp_err_t nvs_set_blob(nvs_handle handle, const char* key, const void* value, size_t length);
+esp_err_t nvs_set_blob(nvs_handle_t handle, const char* key, const void* value, size_t length);
 
 /**@{*/
 /**
@@ -244,14 +254,14 @@ esp_err_t nvs_set_blob(nvs_handle handle, const char* key, const void* value, si
  *             - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints
  *             - ESP_ERR_NVS_INVALID_LENGTH if length is not sufficient to store data
  */
-esp_err_t nvs_get_i8  (nvs_handle handle, const char* key, int8_t* out_value);
-esp_err_t nvs_get_u8  (nvs_handle handle, const char* key, uint8_t* out_value);
-esp_err_t nvs_get_i16 (nvs_handle handle, const char* key, int16_t* out_value);
-esp_err_t nvs_get_u16 (nvs_handle handle, const char* key, uint16_t* out_value);
-esp_err_t nvs_get_i32 (nvs_handle handle, const char* key, int32_t* out_value);
-esp_err_t nvs_get_u32 (nvs_handle handle, const char* key, uint32_t* out_value);
-esp_err_t nvs_get_i64 (nvs_handle handle, const char* key, int64_t* out_value);
-esp_err_t nvs_get_u64 (nvs_handle handle, const char* key, uint64_t* out_value);
+esp_err_t nvs_get_i8  (nvs_handle_t handle, const char* key, int8_t* out_value);
+esp_err_t nvs_get_u8  (nvs_handle_t handle, const char* key, uint8_t* out_value);
+esp_err_t nvs_get_i16 (nvs_handle_t handle, const char* key, int16_t* out_value);
+esp_err_t nvs_get_u16 (nvs_handle_t handle, const char* key, uint16_t* out_value);
+esp_err_t nvs_get_i32 (nvs_handle_t handle, const char* key, int32_t* out_value);
+esp_err_t nvs_get_u32 (nvs_handle_t handle, const char* key, uint32_t* out_value);
+esp_err_t nvs_get_i64 (nvs_handle_t handle, const char* key, int64_t* out_value);
+esp_err_t nvs_get_u64 (nvs_handle_t handle, const char* key, uint64_t* out_value);
 /**@}*/ 
 
 /**
@@ -311,8 +321,8 @@ esp_err_t nvs_get_u64 (nvs_handle handle, const char* key, uint64_t* out_value);
  *             - ESP_ERR_NVS_INVALID_LENGTH if length is not sufficient to store data
  */
 /**@{*/
-esp_err_t nvs_get_str (nvs_handle handle, const char* key, char* out_value, size_t* length);
-esp_err_t nvs_get_blob(nvs_handle handle, const char* key, void* out_value, size_t* length);
+esp_err_t nvs_get_str (nvs_handle_t handle, const char* key, char* out_value, size_t* length);
+esp_err_t nvs_get_blob(nvs_handle_t handle, const char* key, void* out_value, size_t* length);
 /**@}*/
 
 /**
@@ -334,7 +344,7 @@ esp_err_t nvs_get_blob(nvs_handle handle, const char* key, void* out_value, size
  *              - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist
  *              - other error codes from the underlying storage driver
  */
-esp_err_t nvs_erase_key(nvs_handle handle, const char* key);
+esp_err_t nvs_erase_key(nvs_handle_t handle, const char* key);
 
 /**
  * @brief      Erase all key-value pairs in a namespace
@@ -350,7 +360,7 @@ esp_err_t nvs_erase_key(nvs_handle handle, const char* key);
  *              - ESP_ERR_NVS_READ_ONLY if handle was opened as read only
  *              - other error codes from the underlying storage driver
  */
-esp_err_t nvs_erase_all(nvs_handle handle);
+esp_err_t nvs_erase_all(nvs_handle_t handle);
 
 /**
  * @brief      Write any pending changes to non-volatile storage
@@ -367,7 +377,7 @@ esp_err_t nvs_erase_all(nvs_handle handle);
  *             - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL
  *             - other error codes from the underlying storage driver
  */
-esp_err_t nvs_commit(nvs_handle handle);
+esp_err_t nvs_commit(nvs_handle_t handle);
 
 /**
  * @brief      Close the storage handle and free any allocated resources
@@ -380,7 +390,7 @@ esp_err_t nvs_commit(nvs_handle handle);
  *
  * @param[in]  handle  Storage handle to close
  */
-void nvs_close(nvs_handle handle);
+void nvs_close(nvs_handle_t handle);
 
 /**
  * @note Info about storage space NVS.
@@ -436,7 +446,7 @@ esp_err_t nvs_get_stats(const char* part_name, nvs_stats_t* nvs_stats);
  *
  * \code{c}
  * // Example of nvs_get_used_entry_count() to get amount of all key-value pairs in one namespace:
- * nvs_handle handle;
+ * nvs_handle_t handle;
  * nvs_open("namespace1", NVS_READWRITE, &handle);
  * ...
  * size_t used_entries;
@@ -463,7 +473,7 @@ esp_err_t nvs_get_stats(const char* part_name, nvs_stats_t* nvs_stats);
  *             - Other error codes from the underlying storage driver.
  *               Return param used_entries will be filled 0.
  */
-esp_err_t nvs_get_used_entry_count(nvs_handle handle, size_t* used_entries);
+esp_err_t nvs_get_used_entry_count(nvs_handle_t handle, size_t* used_entries);
 
 #ifdef __cplusplus
 } // extern "C"
index da905922d56487c598224263bf542c36ea078a4d..6898227dc5d67a88502d53c9d716c958f9f9a148 100644 (file)
@@ -55,7 +55,7 @@ public:
     {
     }
 
-    nvs_handle mHandle;
+    nvs_handle_t mHandle;
     uint8_t mReadOnly;
     uint8_t mNsIndex;
     nvs::Storage* mStoragePtr;
@@ -253,7 +253,7 @@ extern "C" esp_err_t nvs_flash_deinit(void)
     return nvs_flash_deinit_partition(NVS_DEFAULT_PART_NAME);
 }
 
-static esp_err_t nvs_find_ns_handle(nvs_handle handle, HandleEntry& entry)
+static esp_err_t nvs_find_ns_handle(nvs_handle_t handle, HandleEntry& entry)
 {
     auto it = find_if(begin(s_nvs_handles), end(s_nvs_handles), [=](HandleEntry& e) -> bool {
         return e.mHandle == handle;
@@ -265,7 +265,7 @@ static esp_err_t nvs_find_ns_handle(nvs_handle handle, HandleEntry& entry)
     return ESP_OK;
 }
 
-extern "C" esp_err_t nvs_open_from_partition(const char *part_name, const char* name, nvs_open_mode open_mode, nvs_handle *out_handle)
+extern "C" esp_err_t nvs_open_from_partition(const char *part_name, const char* name, nvs_open_mode_t open_mode, nvs_handle_t *out_handle)
 {
     Lock lock;
     ESP_LOGD(TAG, "%s %s %d", __func__, name, open_mode);
@@ -290,7 +290,7 @@ extern "C" esp_err_t nvs_open_from_partition(const char *part_name, const char*
     return ESP_OK;
 }
 
-extern "C" esp_err_t nvs_open(const char* name, nvs_open_mode open_mode, nvs_handle *out_handle)
+extern "C" esp_err_t nvs_open(const char* name, nvs_open_mode_t open_mode, nvs_handle_t *out_handle)
 {
     if (s_nvs_storage_list.size() == 0) {
         return ESP_ERR_NVS_NOT_INITIALIZED;
@@ -299,7 +299,7 @@ extern "C" esp_err_t nvs_open(const char* name, nvs_open_mode open_mode, nvs_han
     return nvs_open_from_partition(NVS_DEFAULT_PART_NAME, name, open_mode, out_handle);
 }
 
-extern "C" void nvs_close(nvs_handle handle)
+extern "C" void nvs_close(nvs_handle_t handle)
 {
     Lock lock;
     ESP_LOGD(TAG, "%s %d", __func__, handle);
@@ -313,7 +313,7 @@ extern "C" void nvs_close(nvs_handle handle)
     delete static_cast<HandleEntry*>(it);
 }
 
-extern "C" esp_err_t nvs_erase_key(nvs_handle handle, const char* key)
+extern "C" esp_err_t nvs_erase_key(nvs_handle_t handle, const char* key)
 {
     Lock lock;
     ESP_LOGD(TAG, "%s %s\r\n", __func__, key);
@@ -328,7 +328,7 @@ extern "C" esp_err_t nvs_erase_key(nvs_handle handle, const char* key)
     return entry.mStoragePtr->eraseItem(entry.mNsIndex, key);
 }
 
-extern "C" esp_err_t nvs_erase_all(nvs_handle handle)
+extern "C" esp_err_t nvs_erase_all(nvs_handle_t handle)
 {
     Lock lock;
     ESP_LOGD(TAG, "%s\r\n", __func__);
@@ -344,7 +344,7 @@ extern "C" esp_err_t nvs_erase_all(nvs_handle handle)
 }
 
 template<typename T>
-static esp_err_t nvs_set(nvs_handle handle, const char* key, T value)
+static esp_err_t nvs_set(nvs_handle_t handle, const char* key, T value)
 {
     Lock lock;
     ESP_LOGD(TAG, "%s %s %d %d", __func__, key, sizeof(T), (uint32_t) value);
@@ -359,47 +359,47 @@ static esp_err_t nvs_set(nvs_handle handle, const char* key, T value)
     return entry.mStoragePtr->writeItem(entry.mNsIndex, key, value);
 }
 
-extern "C" esp_err_t nvs_set_i8  (nvs_handle handle, const char* key, int8_t value)
+extern "C" esp_err_t nvs_set_i8  (nvs_handle_t handle, const char* key, int8_t value)
 {
     return nvs_set(handle, key, value);
 }
 
-extern "C" esp_err_t nvs_set_u8  (nvs_handle handle, const char* key, uint8_t value)
+extern "C" esp_err_t nvs_set_u8  (nvs_handle_t handle, const char* key, uint8_t value)
 {
     return nvs_set(handle, key, value);
 }
 
-extern "C" esp_err_t nvs_set_i16 (nvs_handle handle, const char* key, int16_t value)
+extern "C" esp_err_t nvs_set_i16 (nvs_handle_t handle, const char* key, int16_t value)
 {
     return nvs_set(handle, key, value);
 }
 
-extern "C" esp_err_t nvs_set_u16 (nvs_handle handle, const char* key, uint16_t value)
+extern "C" esp_err_t nvs_set_u16 (nvs_handle_t handle, const char* key, uint16_t value)
 {
     return nvs_set(handle, key, value);
 }
 
-extern "C" esp_err_t nvs_set_i32 (nvs_handle handle, const char* key, int32_t value)
+extern "C" esp_err_t nvs_set_i32 (nvs_handle_t handle, const char* key, int32_t value)
 {
     return nvs_set(handle, key, value);
 }
 
-extern "C" esp_err_t nvs_set_u32 (nvs_handle handle, const char* key, uint32_t value)
+extern "C" esp_err_t nvs_set_u32 (nvs_handle_t handle, const char* key, uint32_t value)
 {
     return nvs_set(handle, key, value);
 }
 
-extern "C" esp_err_t nvs_set_i64 (nvs_handle handle, const char* key, int64_t value)
+extern "C" esp_err_t nvs_set_i64 (nvs_handle_t handle, const char* key, int64_t value)
 {
     return nvs_set(handle, key, value);
 }
 
-extern "C" esp_err_t nvs_set_u64 (nvs_handle handle, const char* key, uint64_t value)
+extern "C" esp_err_t nvs_set_u64 (nvs_handle_t handle, const char* key, uint64_t value)
 {
     return nvs_set(handle, key, value);
 }
 
-extern "C" esp_err_t nvs_commit(nvs_handle handle)
+extern "C" esp_err_t nvs_commit(nvs_handle_t handle)
 {
     Lock lock;
     // no-op for now, to be used when intermediate cache is added
@@ -407,7 +407,7 @@ extern "C" esp_err_t nvs_commit(nvs_handle handle)
     return nvs_find_ns_handle(handle, entry);
 }
 
-extern "C" esp_err_t nvs_set_str(nvs_handle handle, const char* key, const char* value)
+extern "C" esp_err_t nvs_set_str(nvs_handle_t handle, const char* key, const char* value)
 {
     Lock lock;
     ESP_LOGD(TAG, "%s %s %s", __func__, key, value);
@@ -419,7 +419,7 @@ extern "C" esp_err_t nvs_set_str(nvs_handle handle, const char* key, const char*
     return entry.mStoragePtr->writeItem(entry.mNsIndex, nvs::ItemType::SZ, key, value, strlen(value) + 1);
 }
 
-extern "C" esp_err_t nvs_set_blob(nvs_handle handle, const char* key, const void* value, size_t length)
+extern "C" esp_err_t nvs_set_blob(nvs_handle_t handle, const char* key, const void* value, size_t length)
 {
     Lock lock;
     ESP_LOGD(TAG, "%s %s %d", __func__, key, length);
@@ -433,7 +433,7 @@ extern "C" esp_err_t nvs_set_blob(nvs_handle handle, const char* key, const void
 
 
 template<typename T>
-static esp_err_t nvs_get(nvs_handle handle, const char* key, T* out_value)
+static esp_err_t nvs_get(nvs_handle_t handle, const char* key, T* out_value)
 {
     Lock lock;
     ESP_LOGD(TAG, "%s %s %d", __func__, key, sizeof(T));
@@ -445,47 +445,47 @@ static esp_err_t nvs_get(nvs_handle handle, const char* key, T* out_value)
     return entry.mStoragePtr->readItem(entry.mNsIndex, key, *out_value);
 }
 
-extern "C" esp_err_t nvs_get_i8  (nvs_handle handle, const char* key, int8_t* out_value)
+extern "C" esp_err_t nvs_get_i8  (nvs_handle_t handle, const char* key, int8_t* out_value)
 {
     return nvs_get(handle, key, out_value);
 }
 
-extern "C" esp_err_t nvs_get_u8  (nvs_handle handle, const char* key, uint8_t* out_value)
+extern "C" esp_err_t nvs_get_u8  (nvs_handle_t handle, const char* key, uint8_t* out_value)
 {
     return nvs_get(handle, key, out_value);
 }
 
-extern "C" esp_err_t nvs_get_i16 (nvs_handle handle, const char* key, int16_t* out_value)
+extern "C" esp_err_t nvs_get_i16 (nvs_handle_t handle, const char* key, int16_t* out_value)
 {
     return nvs_get(handle, key, out_value);
 }
 
-extern "C" esp_err_t nvs_get_u16 (nvs_handle handle, const char* key, uint16_t* out_value)
+extern "C" esp_err_t nvs_get_u16 (nvs_handle_t handle, const char* key, uint16_t* out_value)
 {
     return nvs_get(handle, key, out_value);
 }
 
-extern "C" esp_err_t nvs_get_i32 (nvs_handle handle, const char* key, int32_t* out_value)
+extern "C" esp_err_t nvs_get_i32 (nvs_handle_t handle, const char* key, int32_t* out_value)
 {
     return nvs_get(handle, key, out_value);
 }
 
-extern "C" esp_err_t nvs_get_u32 (nvs_handle handle, const char* key, uint32_t* out_value)
+extern "C" esp_err_t nvs_get_u32 (nvs_handle_t handle, const char* key, uint32_t* out_value)
 {
     return nvs_get(handle, key, out_value);
 }
 
-extern "C" esp_err_t nvs_get_i64 (nvs_handle handle, const char* key, int64_t* out_value)
+extern "C" esp_err_t nvs_get_i64 (nvs_handle_t handle, const char* key, int64_t* out_value)
 {
     return nvs_get(handle, key, out_value);
 }
 
-extern "C" esp_err_t nvs_get_u64 (nvs_handle handle, const char* key, uint64_t* out_value)
+extern "C" esp_err_t nvs_get_u64 (nvs_handle_t handle, const char* key, uint64_t* out_value)
 {
     return nvs_get(handle, key, out_value);
 }
 
-static esp_err_t nvs_get_str_or_blob(nvs_handle handle, nvs::ItemType type, const char* key, void* out_value, size_t* length)
+static esp_err_t nvs_get_str_or_blob(nvs_handle_t handle, nvs::ItemType type, const char* key, void* out_value, size_t* length)
 {
     Lock lock;
     ESP_LOGD(TAG, "%s %s", __func__, key);
@@ -515,12 +515,12 @@ static esp_err_t nvs_get_str_or_blob(nvs_handle handle, nvs::ItemType type, cons
     return entry.mStoragePtr->readItem(entry.mNsIndex, type, key, out_value, dataSize);
 }
 
-extern "C" esp_err_t nvs_get_str(nvs_handle handle, const char* key, char* out_value, size_t* length)
+extern "C" esp_err_t nvs_get_str(nvs_handle_t handle, const char* key, char* out_value, size_t* length)
 {
     return nvs_get_str_or_blob(handle, nvs::ItemType::SZ, key, out_value, length);
 }
 
-extern "C" esp_err_t nvs_get_blob(nvs_handle handle, const char* key, void* out_value, size_t* length)
+extern "C" esp_err_t nvs_get_blob(nvs_handle_t handle, const char* key, void* out_value, size_t* length)
 {
     return nvs_get_str_or_blob(handle, nvs::ItemType::BLOB, key, out_value, length);
 }
@@ -550,7 +550,7 @@ extern "C" esp_err_t nvs_get_stats(const char* part_name, nvs_stats_t* nvs_stats
     return pStorage->fillStats(*nvs_stats);
 }
 
-extern "C" esp_err_t nvs_get_used_entry_count(nvs_handle handle, size_t* used_entries)
+extern "C" esp_err_t nvs_get_used_entry_count(nvs_handle_t handle, size_t* used_entries)
 {
     Lock lock;
     if(used_entries == NULL){
index a8667dc0166560cfd403c01aee3fb13c19a19019..0c86f4756de5e531056e2cffbcd279d2c35bc73f 100644 (file)
@@ -20,7 +20,7 @@ static const char* TAG = "test_nvs";
 
 TEST_CASE("various nvs tests", "[nvs]")
 {
-    nvs_handle handle_1;
+    nvs_handle_t handle_1;
     esp_err_t err = nvs_flash_init();
     if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
         ESP_LOGW(TAG, "nvs_flash_init failed (0x%x), erasing partition and retrying", err);
@@ -42,7 +42,7 @@ TEST_CASE("various nvs tests", "[nvs]")
     TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x12345678));
     TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x23456789));
 
-    nvs_handle handle_2;
+    nvs_handle_t handle_2;
     TEST_ESP_OK(nvs_open("test_namespace3", NVS_READWRITE, &handle_2));
     TEST_ESP_OK(nvs_erase_all(handle_2));
     TEST_ESP_OK(nvs_set_i32(handle_2, "foo", 0x3456789a));
@@ -83,7 +83,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
     TEST_ASSERT_TRUE(stat1.total_entries == 0);
     TEST_ASSERT_TRUE(stat1.used_entries == 0);
 
-    nvs_handle handle = 0;
+    nvs_handle_t handle = 0;
     size_t h_count_entries;
     TEST_ESP_ERR(nvs_get_used_entry_count(handle, &h_count_entries), ESP_ERR_NVS_INVALID_HANDLE);
     TEST_ASSERT_TRUE(h_count_entries == 0);
@@ -115,7 +115,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
     TEST_ASSERT_TRUE(stat1.used_entries == 0);
 
     // create namespace test_k1
-    nvs_handle handle_1;
+    nvs_handle_t handle_1;
     TEST_ESP_OK(nvs_open("test_k1", NVS_READWRITE, &handle_1));
     TEST_ESP_OK(nvs_get_stats(NULL, &stat2));
     TEST_ASSERT_TRUE(stat2.free_entries + 1 == stat1.free_entries);
@@ -152,7 +152,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
     TEST_ESP_OK(nvs_get_used_entry_count(handle_1, &h1_count_entries));
     TEST_ASSERT_TRUE(h1_count_entries == 2);
 
-    nvs_handle handle_2;
+    nvs_handle_t handle_2;
     // create namespace test_k2
     TEST_ESP_OK(nvs_open("test_k2", NVS_READWRITE, &handle_2));
     TEST_ESP_OK(nvs_get_stats(NULL, &stat2));
@@ -189,7 +189,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
     h2_count_entries = temp;
     TEST_ESP_ERR(nvs_get_used_entry_count(handle_1, NULL), ESP_ERR_INVALID_ARG);
 
-    nvs_handle handle_3;
+    nvs_handle_t handle_3;
     // create namespace test_k3
     TEST_ESP_OK(nvs_open("test_k3", NVS_READWRITE, &handle_3));
     TEST_ESP_OK(nvs_get_stats(NULL, &stat2));
@@ -230,7 +230,7 @@ TEST_CASE("check for memory leaks in nvs_set_blob", "[nvs]")
     TEST_ESP_OK( err );
 
     for (int i = 0; i < 500; ++i) {
-        nvs_handle my_handle;
+        nvs_handle_t my_handle;
         uint8_t key[20] = {0};
 
         TEST_ESP_OK( nvs_open("test_namespace1", NVS_READWRITE, &my_handle) );
@@ -346,7 +346,7 @@ TEST_CASE("test nvs apis with encryption enabled", "[nvs]")
         }
         TEST_ESP_OK(nvs_flash_secure_init(&cfg));
 
-        nvs_handle handle_1;
+        nvs_handle_t handle_1;
 
         TEST_ESP_ERR(nvs_open("namespace1", NVS_READONLY, &handle_1), ESP_ERR_NVS_NOT_FOUND);
 
@@ -356,7 +356,7 @@ TEST_CASE("test nvs apis with encryption enabled", "[nvs]")
         TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x12345678));
         TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x23456789));
 
-        nvs_handle handle_2;
+        nvs_handle_t handle_2;
         TEST_ESP_OK(nvs_open("namespace2", NVS_READWRITE, &handle_2));
         TEST_ESP_OK(nvs_set_i32(handle_2, "foo", 0x3456789a));
         const char* str = "value 0123456789abcdef0123456789abcdef";
@@ -403,7 +403,7 @@ TEST_CASE("test nvs apis for nvs partition generator utility with encryption ena
         TEST_IGNORE_MESSAGE("flash encryption disabled, skipping nvs_api tests with encryption enabled");
     }
 
-    nvs_handle handle;
+    nvs_handle_t handle;
     nvs_sec_cfg_t xts_cfg;
 
     extern const char nvs_key_start[] asm("_binary_encryption_keys_bin_start");
index 126b1bc286de32296672eb1b24d94dde8236e707..3cfa2b0e46e0dcfc191a144c8cc983ca69727f2e 100644 (file)
@@ -552,7 +552,7 @@ TEST_CASE("nvs api tests", "[nvs]")
     SpiFlashEmulator emu(10);
     emu.randomize(100);
 
-    nvs_handle handle_1;
+    nvs_handle_t handle_1;
     const uint32_t NVS_FLASH_SECTOR = 6;
     const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
     emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
@@ -573,7 +573,7 @@ TEST_CASE("nvs api tests", "[nvs]")
     TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x12345678));
     TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x23456789));
 
-    nvs_handle handle_2;
+    nvs_handle_t handle_2;
     TEST_ESP_OK(nvs_open("namespace2", NVS_READWRITE, &handle_2));
     TEST_ESP_OK(nvs_set_i32(handle_2, "foo", 0x3456789a));
     const char* str = "value 0123456789abcdef0123456789abcdef";
@@ -620,7 +620,7 @@ TEST_CASE("wifi test", "[nvs]")
     emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
 
-    nvs_handle misc_handle;
+    nvs_handle_t misc_handle;
     TEST_ESP_OK(nvs_open("nvs.net80211", NVS_READWRITE, &misc_handle));
     char log[33];
     size_t log_size = sizeof(log);
@@ -628,7 +628,7 @@ TEST_CASE("wifi test", "[nvs]")
     strcpy(log, "foobarbazfizzz");
     TEST_ESP_OK(nvs_set_str(misc_handle, "log", log));
 
-    nvs_handle net80211_handle;
+    nvs_handle_t net80211_handle;
     TEST_ESP_OK(nvs_open("nvs.net80211", NVS_READWRITE, &net80211_handle));
 
     uint8_t opmode = 2;
@@ -808,7 +808,7 @@ TEST_CASE("can init storage from flash with random contents", "[nvs]")
     SpiFlashEmulator emu(10);
     emu.randomize(42);
 
-    nvs_handle handle;
+    nvs_handle_t handle;
     const uint32_t NVS_FLASH_SECTOR = 5;
     const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
     emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
@@ -842,13 +842,13 @@ TEST_CASE("nvs api tests, starting with random data in flash", "[nvs][long]")
 
         TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
 
-        nvs_handle handle_1;
+        nvs_handle_t handle_1;
         TEST_ESP_ERR(nvs_open("namespace1", NVS_READONLY, &handle_1), ESP_ERR_NVS_NOT_FOUND);
 
         TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle_1));
         TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x12345678));
         for (size_t i = 0; i < 500; ++i) {
-            nvs_handle handle_2;
+            nvs_handle_t handle_2;
             TEST_ESP_OK(nvs_open("namespace2", NVS_READWRITE, &handle_2));
             TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x23456789 % (i + 1)));
             TEST_ESP_OK(nvs_set_i32(handle_2, "foo", static_cast<int32_t>(i)));
@@ -897,7 +897,7 @@ public:
     }
 
     template<typename TGen>
-    esp_err_t doRandomThings(nvs_handle handle, TGen gen, size_t& count) {
+    esp_err_t doRandomThings(nvs_handle_t handle, TGen gen, size_t& count) {
 
         const char* keys[] = {"foo", "bar", "longkey_0123456", "another key", "param1", "param2", "param3", "param4", "param5", "singlepage", "multipage"};
         const ItemType types[] = {ItemType::I32, ItemType::I32, ItemType::U64, ItemType::U64, ItemType::SZ, ItemType::SZ, ItemType::SZ, ItemType::SZ, ItemType::SZ, ItemType::BLOB, ItemType::BLOB};
@@ -1150,7 +1150,7 @@ TEST_CASE("monkey test", "[nvs][monkey]")
 
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
 
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
     RandomTest test;
     size_t count = 1000;
@@ -1192,7 +1192,7 @@ TEST_CASE("test recovery from sudden poweroff", "[long][nvs][recovery][monkey]")
         }
 
 
-        nvs_handle handle;
+        nvs_handle_t handle;
         size_t count = iter_count;
 
         if (nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN) == ESP_OK) {
@@ -1225,7 +1225,7 @@ TEST_CASE("test for memory leaks in open/set", "[leaks]")
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
 
     for (int i = 0; i < 100000; ++i) {
-        nvs_handle light_handle = 0;
+        nvs_handle_t light_handle = 0;
         char lightbulb[1024] = {12, 13, 14, 15, 16};
         TEST_ESP_OK(nvs_open("light", NVS_READWRITE, &light_handle));
         TEST_ESP_OK(nvs_set_blob(light_handle, "key", lightbulb, sizeof(lightbulb)));
@@ -1380,7 +1380,7 @@ TEST_CASE("read/write failure (TW8406)", "[nvs]")
     nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3);
     for (int attempts = 0; attempts < 3; ++attempts) {
         int i = 0;
-        nvs_handle light_handle = 0;
+        nvs_handle_t light_handle = 0;
         char key[15] = {0};
         char data[76] = {12, 13, 14, 15, 16};
         uint8_t number = 20;
@@ -1412,7 +1412,7 @@ TEST_CASE("nvs_flash_init checks for an empty page", "[nvs]")
     uint8_t blob[blob_size] = {0};
     SpiFlashEmulator emu(5);
     TEST_ESP_OK( nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5) );
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK( nvs_open("test", NVS_READWRITE, &handle) );
     // Fill first page
     TEST_ESP_OK( nvs_set_blob(handle, "1a", blob, blob_size) );
@@ -1432,7 +1432,7 @@ TEST_CASE("multiple partitions access check", "[nvs]")
     SpiFlashEmulator emu(10);
     TEST_ESP_OK( nvs_flash_init_custom("nvs1", 0, 5) );
     TEST_ESP_OK( nvs_flash_init_custom("nvs2", 5, 5) );
-    nvs_handle handle1, handle2;
+    nvs_handle_t handle1, handle2;
     TEST_ESP_OK( nvs_open_from_partition("nvs1", "test", NVS_READWRITE, &handle1) );
     TEST_ESP_OK( nvs_open_from_partition("nvs2", "test", NVS_READWRITE, &handle2) );
     TEST_ESP_OK( nvs_set_i32(handle1, "foo", 0xdeadbeef));
@@ -1450,7 +1450,7 @@ TEST_CASE("nvs page selection takes into account free entries also not just eras
     uint8_t blob[blob_size] = {0};
     SpiFlashEmulator emu(3);
     TEST_ESP_OK( nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3) );
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK( nvs_open("test", NVS_READWRITE, &handle) );
     // Fill first page
     TEST_ESP_OK( nvs_set_blob(handle, "1a", blob, blob_size/3) );
@@ -1478,7 +1478,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
     CHECK(stat1.total_entries == 0);
     CHECK(stat1.used_entries == 0);
 
-    nvs_handle handle = 0;
+    nvs_handle_t handle = 0;
     size_t h_count_entries;
     TEST_ESP_ERR(nvs_get_used_entry_count(handle, &h_count_entries), ESP_ERR_NVS_INVALID_HANDLE);
     CHECK(h_count_entries == 0);
@@ -1498,7 +1498,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
     CHECK(stat1.used_entries == 0);
 
     // create namespace test_k1
-    nvs_handle handle_1;
+    nvs_handle_t handle_1;
     TEST_ESP_OK(nvs_open("test_k1", NVS_READWRITE, &handle_1));
     TEST_ESP_OK(nvs_get_stats(NULL, &stat2));
     CHECK(stat2.free_entries + 1 == stat1.free_entries);
@@ -1535,7 +1535,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
     TEST_ESP_OK(nvs_get_used_entry_count(handle_1, &h1_count_entries));
     CHECK(h1_count_entries == 2);
 
-    nvs_handle handle_2;
+    nvs_handle_t handle_2;
     // create namespace test_k2
     TEST_ESP_OK(nvs_open("test_k2", NVS_READWRITE, &handle_2));
     TEST_ESP_OK(nvs_get_stats(NULL, &stat2));
@@ -1572,7 +1572,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
     h2_count_entries = temp;
     TEST_ESP_ERR(nvs_get_used_entry_count(handle_1, NULL), ESP_ERR_INVALID_ARG);
 
-    nvs_handle handle_3;
+    nvs_handle_t handle_3;
     // create namespace test_k3
     TEST_ESP_OK(nvs_open("test_k3", NVS_READWRITE, &handle_3));
     TEST_ESP_OK(nvs_get_stats(NULL, &stat2));
@@ -1607,7 +1607,7 @@ TEST_CASE("Recovery from power-off when the entry being erased is not on active
     uint8_t blob[blob_size] = {0x11};
     SpiFlashEmulator emu(3);
     TEST_ESP_OK( nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3) );
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK( nvs_open("test", NVS_READWRITE, &handle) );
 
     emu.clearStats();
@@ -1635,7 +1635,7 @@ TEST_CASE("Recovery from power-off when page is being freed.", "[nvs]")
     uint8_t blob[blob_size] = {0};
     SpiFlashEmulator emu(3);
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3));
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK(nvs_open("test", NVS_READWRITE, &handle));
     // Fill first page
     TEST_ESP_OK(nvs_set_blob(handle, "1a", blob, blob_size/3));
@@ -1675,7 +1675,7 @@ TEST_CASE("Multi-page blobs are supported", "[nvs]")
     uint8_t blob[blob_size] = {0};
     SpiFlashEmulator emu(5);
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5));
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK(nvs_open("test", NVS_READWRITE, &handle));
     TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, blob_size));
     TEST_ESP_OK(nvs_commit(handle));
@@ -1688,7 +1688,7 @@ TEST_CASE("Failures are handled while storing multi-page blobs", "[nvs]")
     uint8_t blob[blob_size] = {0};
     SpiFlashEmulator emu(5);
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5));
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK(nvs_open("test", NVS_READWRITE, &handle));
     TEST_ESP_ERR(nvs_set_blob(handle, "abc", blob, blob_size), ESP_ERR_NVS_VALUE_TOO_LONG);
     TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, Page::CHUNK_MAX_SIZE*2));
@@ -1704,7 +1704,7 @@ TEST_CASE("Reading multi-page blobs", "[nvs]")
     size_t read_size = blob_size;
     SpiFlashEmulator emu(5);
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5));
-    nvs_handle handle;
+    nvs_handle_t handle;
     memset(blob, 0x11, blob_size);
     memset(blob_read, 0xee, blob_size);
     TEST_ESP_OK(nvs_open("readTest", NVS_READWRITE, &handle));
@@ -1726,7 +1726,7 @@ TEST_CASE("Modification of values for Multi-page blobs are supported", "[nvs]")
     size_t read_size = blob_size;
     SpiFlashEmulator emu(6);
     TEST_ESP_OK( nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 6) );
-    nvs_handle handle;
+    nvs_handle_t handle;
     memset(blob, 0x11, blob_size);
     memset(blob2, 0x22, blob_size);
     memset(blob3, 0x33, blob_size);
@@ -1751,7 +1751,7 @@ TEST_CASE("Modification from single page blob to multi-page", "[nvs]")
     size_t read_size = blob_size;
     SpiFlashEmulator emu(5);
     TEST_ESP_OK( nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5) );
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK(nvs_open("Test", NVS_READWRITE, &handle) );
     TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, Page::CHUNK_MAX_SIZE/2));
     TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, blob_size));
@@ -1769,7 +1769,7 @@ TEST_CASE("Modification from  multi-page to single page", "[nvs]")
     size_t read_size = blob_size;
     SpiFlashEmulator emu(5);
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5) );
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK(nvs_open("Test", NVS_READWRITE, &handle) );
     TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, blob_size));
     TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, Page::CHUNK_MAX_SIZE/2));
@@ -1836,7 +1836,7 @@ TEST_CASE("nvs blob fragmentation test", "[nvs]")
     CHECK(blob != NULL);
     memset(blob, 0xEE, BLOB_SIZE);
     const uint32_t magic = 0xff33eaeb;
-    nvs_handle h;
+    nvs_handle_t h;
     TEST_ESP_OK( nvs_open("blob_tests", NVS_READWRITE, &h) );
     for (int i = 0; i < 128; i++) {
         INFO("Iteration " << i << "...\n");
@@ -1887,7 +1887,7 @@ TEST_CASE("Check for nvs version incompatibility", "[nvs]")
 TEST_CASE("Check that NVS supports old blob format without blob index", "[nvs]")
 {
     SpiFlashEmulator emu("../nvs_partition_generator/part_old_blob_format.bin");
-    nvs_handle handle;
+    nvs_handle_t handle;
 
     TEST_ESP_OK( nvs_flash_init_custom("test", 0, 2) );
     TEST_ESP_OK( nvs_open_from_partition("test", "dummyNamespace", NVS_READONLY, &handle));
@@ -1948,7 +1948,7 @@ TEST_CASE("monkey test with old-format blob present", "[nvs][monkey]")
 
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
 
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
     RandomTest test;
 
@@ -2031,7 +2031,7 @@ TEST_CASE("Recovery from power-off during modification of blob present in old-fo
 
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3));
 
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
 
     uint8_t hexdata[] = {0x01, 0x02, 0x03, 0xab, 0xcd, 0xef};
@@ -2083,7 +2083,7 @@ TEST_CASE("Recovery from power-off during modification of blob present in old-fo
 
     TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3));
 
-    nvs_handle handle;
+    nvs_handle_t handle;
     TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
 
     uint8_t hexdata[] = {0x01, 0x02, 0x03, 0xab, 0xcd, 0xef};
@@ -2129,7 +2129,7 @@ TEST_CASE("Recovery from power-off during modification of blob present in old-fo
 
 static void check_nvs_part_gen_args(char const *part_name, int size, char const *filename, bool is_encr, nvs_sec_cfg_t* xts_cfg)
 {
-    nvs_handle handle;
+    nvs_handle_t handle;
 
     if (is_encr)
         TEST_ESP_OK(nvs_flash_secure_init_custom(part_name, 0, size, xts_cfg));
@@ -2547,7 +2547,7 @@ TEST_CASE("test nvs apis with encryption enabled", "[nvs]")
     SpiFlashEmulator emu(10);
     emu.randomize(100);
 
-    nvs_handle handle_1;
+    nvs_handle_t handle_1;
     const uint32_t NVS_FLASH_SECTOR = 6;
     const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
     emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
@@ -2570,7 +2570,7 @@ TEST_CASE("test nvs apis with encryption enabled", "[nvs]")
     TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x12345678));
     TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x23456789));
 
-    nvs_handle handle_2;
+    nvs_handle_t handle_2;
     TEST_ESP_OK(nvs_open("namespace2", NVS_READWRITE, &handle_2));
     TEST_ESP_OK(nvs_set_i32(handle_2, "foo", 0x3456789a));
     const char* str = "value 0123456789abcdef0123456789abcdef";
index 410ced3f0bdddb61d40c4890218a2cbd0e6f039c..f6b74766e51c229ab146b0dfdeb20526b05fd29f 100644 (file)
@@ -27,7 +27,7 @@
  */
 esp_err_t save_restart_counter(void)
 {
-    nvs_handle my_handle;
+    nvs_handle_t my_handle;
     esp_err_t err;
 
     // Open
@@ -64,7 +64,7 @@ esp_err_t save_restart_counter(void)
  */
 esp_err_t save_run_time(void)
 {
-    nvs_handle my_handle;
+    nvs_handle_t my_handle;
     esp_err_t err;
 
     // Open
@@ -110,7 +110,7 @@ esp_err_t save_run_time(void)
  */
 esp_err_t print_what_saved(void)
 {
-    nvs_handle my_handle;
+    nvs_handle_t my_handle;
     esp_err_t err;
 
     // Open
index cd03269f0da453b5f9028431b4fe2e112387e323..757eeeb303a7f583d75c9bb922c6fbc7cc90cb03 100644 (file)
@@ -31,7 +31,7 @@ void app_main()
     // Open
     printf("\n");
     printf("Opening Non-Volatile Storage (NVS) handle... ");
-    nvs_handle my_handle;
+    nvs_handle_t my_handle;
     err = nvs_open("storage", NVS_READWRITE, &my_handle);
     if (err != ESP_OK) {
         printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err));
index c075496ca6478b6c9baef59514b665ebf11e4874..50fb11e298485704a9af4e1263792097c2cd7947 100644 (file)
@@ -86,7 +86,7 @@ static nvs_type_t str_to_type(const char *type)
     return NVS_TYPE_ANY;
 }
 
-static esp_err_t store_blob(nvs_handle nvs, const char *key, const char *str_values)
+static esp_err_t store_blob(nvs_handle_t nvs, const char *key, const char *str_values)
 {
     uint8_t value;
     size_t str_len = strlen(str_values);
@@ -144,7 +144,7 @@ static void print_blob(const char *blob, size_t len)
 static esp_err_t set_value_in_nvs(const char *key, const char *str_type, const char *str_value)
 {
     esp_err_t err;
-    nvs_handle nvs;
+    nvs_handle_t nvs;
     bool range_error = false;
 
     nvs_type_t type = str_to_type(str_type);
@@ -230,7 +230,7 @@ static esp_err_t set_value_in_nvs(const char *key, const char *str_type, const c
 
 static esp_err_t get_value_from_nvs(const char *key, const char *str_type)
 {
-    nvs_handle nvs;
+    nvs_handle_t nvs;
     esp_err_t err;
 
     nvs_type_t type = str_to_type(str_type);
@@ -314,7 +314,7 @@ static esp_err_t get_value_from_nvs(const char *key, const char *str_type)
 
 static esp_err_t erase(const char *key)
 {
-    nvs_handle nvs;
+    nvs_handle_t nvs;
 
     esp_err_t err = nvs_open(current_namespace, NVS_READWRITE, &nvs);
     if (err == ESP_OK) {
@@ -333,7 +333,7 @@ static esp_err_t erase(const char *key)
 
 static esp_err_t erase_all(const char *name)
 {
-    nvs_handle nvs;
+    nvs_handle_t nvs;
 
     esp_err_t err = nvs_open(current_namespace, NVS_READWRITE, &nvs);
     if (err == ESP_OK) {
index a6e76bacb711fb5ff52b995e554571b40d1326fd..6682294d5918c3590b33d578f18742225c06ed17 100644 (file)
@@ -97,7 +97,7 @@ static void update_pulse_count()
     const char* count_key = "count";
 
     ESP_ERROR_CHECK( nvs_flash_init() );
-    nvs_handle handle;
+    nvs_handle_t handle;
     ESP_ERROR_CHECK( nvs_open(namespace, NVS_READWRITE, &handle));
     uint32_t pulse_count = 0;
     esp_err_t err = nvs_get_u32(handle, count_key, &pulse_count);