Browse Source

fix erase without wifi settings

added minute wise ntp check
pull/452/head
lumapu 2 years ago
parent
commit
657f594307
  1. 1
      src/app.cpp
  2. 9
      src/app.h
  3. 11
      src/config/settings.h
  4. 2
      src/defines.h

1
src/app.cpp

@ -19,6 +19,7 @@ void app::setup(uint32_t timeout) {
yield(); yield();
addListener(EVERY_SEC, std::bind(&app::uptimeTick, this)); addListener(EVERY_SEC, std::bind(&app::uptimeTick, this));
addListener(EVERY_MIN, std::bind(&app::minuteTick, this));
addListener(EVERY_12H, std::bind(&app::ntpUpdateTick, this)); addListener(EVERY_12H, std::bind(&app::ntpUpdateTick, this));
resetSystem(); resetSystem();

9
src/app.h

@ -155,6 +155,8 @@ class app : public ah::Scheduler {
ESP.restart(); ESP.restart();
} }
if (mUpdateNtp) { if (mUpdateNtp) {
mUpdateNtp = false; mUpdateNtp = false;
mUtcTimestamp = mWifi->getNtpTime(); mUtcTimestamp = mWifi->getNtpTime();
@ -162,6 +164,13 @@ class app : public ah::Scheduler {
} }
} }
void minuteTick(void) {
if(0 == mUtcTimestamp) {
if(!mWifi->getApActive())
mUpdateNtp = true;
}
}
void ntpUpdateTick(void) { void ntpUpdateTick(void) {
if (!mWifi->getApActive()) if (!mWifi->getApActive())
mUpdateNtp = true; mUpdateNtp = true;

11
src/config/settings.h

@ -245,13 +245,18 @@ class settings {
private: private:
void loadDefaults(bool wifi = true) { void loadDefaults(bool wifi = true) {
DPRINTLN(DBG_INFO, F("loadDefaults")); DPRINTLN(DBG_INFO, F("loadDefaults"));
memset(&mCfg, 0, sizeof(settings_t));
if(wifi) { if(wifi) {
snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID); snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID);
snprintf(mCfg.sys.stationPwd, PWD_LEN, FB_WIFI_PWD); snprintf(mCfg.sys.stationPwd, PWD_LEN, FB_WIFI_PWD);
snprintf(mCfg.sys.deviceName, DEVNAME_LEN, DEF_DEVICE_NAME);
} }
else {
cfgSys_t tmp;
memset(&tmp.adminPwd, 0, PWD_LEN);
memcpy(&tmp, &mCfg.sys, sizeof(cfgSys_t));
memset(&mCfg, 0, sizeof(settings_t));
memcpy(&mCfg.sys, &tmp, sizeof(cfgSys_t));
}
snprintf(mCfg.sys.deviceName, DEVNAME_LEN, DEF_DEVICE_NAME);
mCfg.nrf.sendInterval = SEND_INTERVAL; mCfg.nrf.sendInterval = SEND_INTERVAL;
mCfg.nrf.maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD; mCfg.nrf.maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD;

2
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 5 #define VERSION_MINOR 5
#define VERSION_PATCH 39 #define VERSION_PATCH 40
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {

Loading…
Cancel
Save