Merge branch 'bugfix/nvs_cxx_example' into 'master'

nvs_flash: fixed wrong error check after open_nvs_handle in example

Closes IDFGH-8809

See merge request espressif/esp-idf!21269
pull/10469/head
Martin Vychodil 2022-12-14 17:17:59 +08:00
commit 732b76e3a0
2 zmienionych plików z 2 dodań i 3 usunięć

Wyświetl plik

@ -224,7 +224,7 @@ protected:
* - ESP_ERR_NVS_INVALID_NAME if namespace name doesn't satisfy constraints
* - other error codes from the underlying storage driver
*
* @return shared pointer of an nvs handle on success, an empty shared pointer otherwise
* @return unique pointer of an nvs handle on success, an empty unique pointer otherwise
*/
std::unique_ptr<NVSHandle> open_nvs_handle_from_partition(const char *partition_name,
const char *ns_name,

Wyświetl plik

@ -33,9 +33,8 @@ extern "C" void app_main(void)
// Open
printf("\n");
printf("Opening Non-Volatile Storage (NVS) handle... ");
esp_err_t result;
// Handle will automatically close when going out of scope or when it's reset.
std::shared_ptr<nvs::NVSHandle> handle = nvs::open_nvs_handle("storage", NVS_READWRITE, &result);
std::unique_ptr<nvs::NVSHandle> handle = nvs::open_nvs_handle("storage", NVS_READWRITE, &err);
if (err != ESP_OK) {
printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err));
} else {