14 lines
470 B
C++
14 lines
470 B
C++
#include "blk_box_drivers/nvs.hpp"
|
|
#include "nvs_flash.h"
|
|
|
|
void init_nvs() {
|
|
// TODO: do more once we are doing more with nvs.
|
|
esp_err_t ret = nvs_flash_init();
|
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
|
// TODO: dont just erase, but also handle the case where we have to upgrade the nvs partition.
|
|
ESP_ERROR_CHECK( nvs_flash_erase() );
|
|
ret = nvs_flash_init();
|
|
}
|
|
ESP_ERROR_CHECK( ret );
|
|
}
|