Add wifi, nvs and inplace_function implementations
This commit is contained in:
26
components/nvs/src/nvs.cpp
Normal file
26
components/nvs/src/nvs.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdexcept>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "nvs_flash.h"
|
||||
|
||||
|
||||
namespace nvs {
|
||||
|
||||
|
||||
void init() {
|
||||
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES ||
|
||||
ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
|
||||
if (nvs_flash_erase() != ESP_OK)
|
||||
throw std::runtime_error("Failed to erase NVS");
|
||||
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
|
||||
if (ret != ESP_OK) throw std::runtime_error("Failed to initialize NVS");
|
||||
}
|
||||
|
||||
|
||||
} // namespace nvs
|
||||
Reference in New Issue
Block a user