Compare commits
3 Commits
main
...
old_versio
Author | SHA1 | Date | |
---|---|---|---|
81356b5828 | |||
0c6c5c905f | |||
8bb58e968c |
@ -66,7 +66,7 @@ template<typename T, T ... ALLOWED_VALUES>
|
||||
ConfigConstraintReturnType OneOf(typename ConfigWrapper<T>::value_t val)
|
||||
{
|
||||
if (!((ALLOWED_VALUES == val) || ...))
|
||||
tl::make_unexpected("Value not one of the allowed ones");
|
||||
return tl::make_unexpected("Value not one of the allowed ones");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,9 @@ public:
|
||||
#endif
|
||||
|
||||
esp_err_t init(const char *ns);
|
||||
|
||||
esp_err_t loadFromFlash();
|
||||
|
||||
//bool erase();
|
||||
ConfigStatusReturnType reset();
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define INSTANTIATE_CONFIGMANAGER_TEMPLATES(Type) \
|
||||
namespace espconfig { \
|
||||
template esp_err_t ConfigManager<Type>::init(const char *ns); \
|
||||
template esp_err_t ConfigManager<Type>::loadFromFlash(); \
|
||||
/* template bool ConfigManager<Type>::erase(); */ \
|
||||
template ConfigStatusReturnType ConfigManager<Type>::reset(); \
|
||||
template ConfigWrapperInterface *ConfigManager<Type>::findConfigByKey(std::string_view key); \
|
||||
@ -108,7 +109,13 @@ esp_err_t ConfigManager<ConfigContainer>::init(const char *ns)
|
||||
|
||||
ESP_LOGI(TAG, "initializing NVS took %lldms", std::chrono::floor<std::chrono::milliseconds>(after-before).count());
|
||||
|
||||
before = espchrono::millis_clock::now();
|
||||
return loadFromFlash();
|
||||
}
|
||||
|
||||
template<typename ConfigContainer>
|
||||
esp_err_t ConfigManager<ConfigContainer>::loadFromFlash()
|
||||
{
|
||||
const auto before = espchrono::millis_clock::now();
|
||||
|
||||
bool success = true;
|
||||
ConfigContainer::callForEveryConfig([&](ConfigWrapperInterface &config){
|
||||
@ -120,7 +127,7 @@ esp_err_t ConfigManager<ConfigContainer>::init(const char *ns)
|
||||
return false; // dont abort the loop
|
||||
});
|
||||
|
||||
after = espchrono::millis_clock::now();
|
||||
const auto after = espchrono::millis_clock::now();
|
||||
|
||||
ESP_LOGI(TAG, "loading all config params took %lldms", std::chrono::floor<std::chrono::milliseconds>(after-before).count());
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#pragma push_macro("LOG_LOCAL_LEVEL")
|
||||
#undef LOG_LOCAL_LEVEL
|
||||
#define LOG_LOCAL_LEVEL CONFIG_LOG_LOCAL_LEVEL_CONFIG
|
||||
|
||||
// system includes
|
||||
@ -175,3 +178,5 @@ ConfigStatusReturnType ConfigWrapper<T>::writeToFlash(nvs_handle_t nvsHandle, va
|
||||
}
|
||||
|
||||
} // namespace espconfig
|
||||
|
||||
#pragma pop_macro("LOG_LOCAL_LEVEL")
|
||||
|
Reference in New Issue
Block a user