implemented:

- save, load, reset functions for config
This commit is contained in:
ZanzyTHEbar 2022-07-24 21:58:13 +01:00
parent 4a8ebffa82
commit f3606676f9

View File

@ -33,18 +33,36 @@ void ProjectConfig::initStructures()
void ProjectConfig::load()
{
log_d("Loading project config");
if (this->_already_loaded)
{
log_d("Project config already loaded");
return;
}
bool device_success = this->read("device", this->config.device);
bool camera_success = this->read("camera", this->config.camera);
bool network_info_success = this->read("network_info", this->config.networks);
if (!device_success || !camera_success || !network_info_success)
{
log_e("Failed to load project config");
this->_already_loaded = false;
return;
}
this->_already_loaded = false;
this->notify(ObserverEvent::configLoaded);
}
void ProjectConfig::save()
{
log_d("Saving project config");
this->write("device", this->config.device);
this->write("camera", this->config.camera);
this->write("network_info", this->config.networks);
}
void ProjectConfig::reset()
{
log_d("Resetting project config");
log_w("Resetting project config");
this->clear();
}
//**********************************************************************************************************************