#pragma once #include "sdkconfig.h" // esp-idf includes #include // local includes #include "configwrapper.h" namespace espconfig { template class ConfigManager : public ConfigContainer { public: using ConfigContainer::ConfigContainer; nvs_handle_t nvs_handle_user{}; #ifdef CONFIG_SEPARATE_FACTORY_NVS_PARTITION nvs_handle_t nvs_handle_factory{}; #endif esp_err_t init(const char *ns); esp_err_t loadFromFlash(); //bool erase(); ConfigStatusReturnType reset(); ConfigWrapperInterface *findConfigByKey(std::string_view key); template ConfigStatusReturnType write_config(ConfigWrapper &config, typename ConfigWrapper::value_t value); inline ConfigStatusReturnType reset_config(ConfigWrapperInterface &config); inline ConfigStatusReturnType force_reset_config(ConfigWrapperInterface &config); }; template template ConfigStatusReturnType ConfigManager::write_config(ConfigWrapper &config, typename ConfigWrapper::value_t value) { return config.write(nvs_handle_user, value); } template inline ConfigStatusReturnType ConfigManager::reset_config(ConfigWrapperInterface &config) { return config.reset(nvs_handle_user); } template inline ConfigStatusReturnType ConfigManager::force_reset_config(ConfigWrapperInterface &config) { return config.forceReset(nvs_handle_user); } } // namespace espconfig