mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-29 08:46:11 +02:00
fix erase without wifi settings
added minute wise ntp check
This commit is contained in:
parent
69855b10a9
commit
657f594307
4 changed files with 19 additions and 4 deletions
|
@ -19,6 +19,7 @@ void app::setup(uint32_t timeout) {
|
|||
yield();
|
||||
|
||||
addListener(EVERY_SEC, std::bind(&app::uptimeTick, this));
|
||||
addListener(EVERY_MIN, std::bind(&app::minuteTick, this));
|
||||
addListener(EVERY_12H, std::bind(&app::ntpUpdateTick, this));
|
||||
|
||||
resetSystem();
|
||||
|
|
|
@ -155,6 +155,8 @@ class app : public ah::Scheduler {
|
|||
ESP.restart();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (mUpdateNtp) {
|
||||
mUpdateNtp = false;
|
||||
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) {
|
||||
if (!mWifi->getApActive())
|
||||
mUpdateNtp = true;
|
||||
|
|
|
@ -245,13 +245,18 @@ class settings {
|
|||
private:
|
||||
void loadDefaults(bool wifi = true) {
|
||||
DPRINTLN(DBG_INFO, F("loadDefaults"));
|
||||
|
||||
memset(&mCfg, 0, sizeof(settings_t));
|
||||
if(wifi) {
|
||||
snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID);
|
||||
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.maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 5
|
||||
#define VERSION_PATCH 39
|
||||
#define VERSION_PATCH 40
|
||||
|
||||
//-------------------------------------
|
||||
typedef struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue