Browse Source

0.5.102

small fixes (save settings)
pull/788/head
lumapu 2 years ago
parent
commit
d7c06fd5d8
  1. 7
      src/app.h
  2. 8
      src/config/settings.h
  3. 9
      src/web/RestApi.h
  4. 4
      src/web/web.h

7
src/app.h

@ -72,7 +72,7 @@ class app : public IApp, public ah::Scheduler {
mShowRebootRequest = true; // only message on index, no reboot
mSavePending = true;
mSaveReboot = reboot;
once(std::bind(&app::tickSave, this), 2, "save");
once(std::bind(&app::tickSave, this), 3, "save");
return true;
}
@ -226,11 +226,12 @@ class app : public IApp, public ah::Scheduler {
}
void tickSave(void) {
mSettings.saveSettings();
if(!mSettings.saveSettings())
mSaveReboot = false;
mSavePending = false;
if(mSaveReboot)
once(std::bind(&app::tickReboot, this), 2, "rboot");
setRebootFlag();
}
void tickNtpUpdate(void);

8
src/config/settings.h

@ -576,18 +576,18 @@ class settings {
obj[F("name")] = cfg->name;
obj[F("sn")] = cfg->serial.u64;
for(uint8_t i = 0; i < 4; i++) {
obj[F("yc")][i] = cfg->yieldCor[i];
obj[F("yield")][i] = cfg->yieldCor[i];
obj[F("pwr")][i] = cfg->chMaxPwr[i];
obj[F("chn")][i] = cfg->chName[i];
obj[F("chName")][i] = cfg->chName[i];
}
} else {
cfg->enabled = (bool)obj[F("en")];
snprintf(cfg->name, MAX_NAME_LENGTH, "%s", obj[F("name")].as<const char*>());
cfg->serial.u64 = obj[F("sn")];
for(uint8_t i = 0; i < 4; i++) {
cfg->yieldCor[i] = obj[F("yc")][i];
cfg->yieldCor[i] = obj[F("yield")][i];
cfg->chMaxPwr[i] = obj[F("pwr")][i];
snprintf(cfg->chName[i], MAX_NAME_LENGTH, "%s", obj[F("chn")][i].as<const char*>());
snprintf(cfg->chName[i], MAX_NAME_LENGTH, "%s", obj[F("chName")][i].as<const char*>());
}
}
}

9
src/web/RestApi.h

@ -80,7 +80,7 @@ class RestApi {
if(path == "html/system") getHtmlSystem(root);
else if(path == "html/logout") getHtmlLogout(root);
else if(path == "html/save") getHtmlSave(root);
else if(path == "html/chk_save") getHtmlChkSave(root);
else if(path == "html/chk_save") getHtmlSave(root);
else if(path == "system") getSysInfo(root);
else if(path == "generic") getGeneric(root);
else if(path == "reboot") getReboot(root);
@ -268,13 +268,6 @@ class RestApi {
void getHtmlSave(JsonObject obj) {
getGeneric(obj.createNestedObject(F("generic")));
obj[F("refresh")] = 1;
obj[F("refresh_url")] = F("/chk_save");
obj[F("html")] = F("saving settings ...");
}
void getHtmlChkSave(JsonObject obj) {
getGeneric(obj.createNestedObject(F("generic")));
obj[F("refresh")] = (mApp->getLastSaveSucceed()) ? 10 : 1;
obj[F("refresh_url")] = mApp->getSavePending() ? F("/chk_save") : F("/setup");
if(mApp->getSavePending())
obj[F("html")] = F("saving settings ...");

4
src/web/web.h

@ -67,8 +67,8 @@ class Web {
mWeb.on("/factory", HTTP_ANY, std::bind(&Web::showFactoryRst, this, std::placeholders::_1));
mWeb.on("/setup", HTTP_GET, std::bind(&Web::onSetup, this, std::placeholders::_1));
mWeb.on("/save", HTTP_ANY, std::bind(&Web::showSave, this, std::placeholders::_1));
mWeb.on("/chk_save", HTTP_ANY, std::bind(&Web::onCheckSave, this, std::placeholders::_1));
mWeb.on("/save", HTTP_POST, std::bind(&Web::showSave, this, std::placeholders::_1));
mWeb.on("/chk_save", HTTP_GET, std::bind(&Web::onCheckSave, this, std::placeholders::_1));
mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1));
//mWeb.on("/api1", HTTP_POST, std::bind(&Web::showWebApi, this, std::placeholders::_1));

Loading…
Cancel
Save