diff --git a/src/CHANGES.md b/src/CHANGES.md
index 671df419..65d938b9 100644
--- a/src/CHANGES.md
+++ b/src/CHANGES.md
@@ -1,5 +1,10 @@
# Changelog
+## 0.5.60
+* added regex to inverter name and MQTT topic (setup.html)
+* beautified serial.html
+* added ticker for wifi loop #515
+
## 0.5.59
* fix night communication enable
* improved different WiFi connection scenarios (STA WiFi not found, reconnect #509, redirect for AP to configuration)
diff --git a/src/app.cpp b/src/app.cpp
index 10fa3c6c..c350f109 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -41,8 +41,11 @@ void app::setup() {
#endif
mWifi.setup(mConfig, &mTimestamp);
+ #if !defined(AP_ONLY)
+ everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi));
+ #endif
- every(std::bind(&app::tickSend, this), mConfig->nrf.sendInterval);
+ mSendTickerId = every(std::bind(&app::tickSend, this), mConfig->nrf.sendInterval);
#if !defined(AP_ONLY)
once(std::bind(&app::tickNtpUpdate, this), 2);
#endif
@@ -78,6 +81,7 @@ void app::setup() {
mPubSerial.setup(mConfig, mSys, &mTimestamp);
every(std::bind(&PubSerialType::tick, &mPubSerial), mConfig->serial.interval);
+ //everySec(std::bind(&app::tickSerial, this));
}
//-----------------------------------------------------------------------------
@@ -85,11 +89,6 @@ void app::loop(void) {
DPRINTLN(DBG_VERBOSE, F("app::loop"));
ah::Scheduler::loop();
-
- #if !defined(AP_ONLY)
- mWifi.loop();
- #endif
-
mSys->Radio.loop();
yield();
@@ -142,7 +141,7 @@ void app::tickCalcSunrise(void) {
ah::calculateSunriseSunset(mTimestamp, mCalculatedTimezoneOffset, mConfig->sun.lat, mConfig->sun.lon, &mSunrise, &mSunset);
tickIVCommunication();
- uint32_t nxtTrig = mTimestamp - ((mTimestamp - 1) % 86400) + 86400; // next midnight, -10 for safety that it is certain next day
+ uint32_t nxtTrig = mTimestamp - ((mTimestamp - 10) % 86400) + 86400; // next midnight, -10 for safety that it is certain next day
onceAt(std::bind(&app::tickCalcSunrise, this), nxtTrig);
if (mConfig->mqtt.broker[0] > 0) {
mMqtt.tickerSun(mSunrise, mSunset, mConfig->sun.offsetSec, mConfig->sun.disNightCom);
@@ -263,6 +262,7 @@ void app::resetSystem(void) {
mSunset = 0;
mRxTicker = 0;
+ mSendTickerId = 0xff; // invalid id
mSendLastIvId = 0;
mShowRebootRequest = false;
diff --git a/src/app.h b/src/app.h
index 0736be22..584f20f8 100644
--- a/src/app.h
+++ b/src/app.h
@@ -191,6 +191,20 @@ class app : public IApp, public ah::Scheduler {
void tickCalcSunrise(void);
void tickIVCommunication(void);
void tickSend(void);
+ /*void tickSerial(void) {
+ if(Serial.available() == 0)
+ return;
+
+ uint8_t buf[80];
+ uint8_t len = Serial.readBytes(buf, 80);
+ DPRINTLN(DBG_INFO, "got serial data, len: " + String(len));
+ for(uint8_t i = 0; i < len; i++) {
+ if((0 != i) && (i % 8 == 0))
+ DBGPRINTLN("");
+ DBGPRINT(String(buf[i], HEX) + " ");
+ }
+ DBGPRINTLN("");
+ }*/
bool mShowRebootRequest;
bool mIVCommunicationOn;
@@ -206,6 +220,7 @@ class app : public IApp, public ah::Scheduler {
settings_t *mConfig;
uint8_t mSendLastIvId;
+ uint8_t mSendTickerId;
statistics_t mStat;
diff --git a/src/defines.h b/src/defines.h
index 14495f21..06c9b8ec 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 5
-#define VERSION_PATCH 59
+#define VERSION_PATCH 60
//-------------------------------------
typedef struct {
diff --git a/src/utils/llist.h b/src/utils/llist.h
index dd139c86..44011846 100644
--- a/src/utils/llist.h
+++ b/src/utils/llist.h
@@ -11,7 +11,7 @@ struct node_s {
typedef T dT;
node_s *pre;
node_s *nxt;
- uint32_t id;
+ uint8_t id;
dT d;
node_s() : pre(NULL), nxt(NULL), d() {}
node_s(Args... args) : id(0), pre(NULL), nxt(NULL), d(args...) {}
diff --git a/src/utils/scheduler.h b/src/utils/scheduler.h
index cfb950cc..fb80d141 100644
--- a/src/utils/scheduler.h
+++ b/src/utils/scheduler.h
@@ -72,8 +72,8 @@ namespace ah {
}
void once(scdCb c, uint32_t timeout) { mStack.add(c, timeout, 0); }
- void every(scdCb c, uint32_t interval) { mStack.add(c, interval, interval); }
void onceAt(scdCb c, uint32_t timestamp) { mStackAt.add(c, timestamp); }
+ uint8_t every(scdCb c, uint32_t interval){ return mStack.add(c, interval, interval)->id; }
void everySec(scdCb c) { mStack.add(c, SCD_SEC, SCD_SEC); }
void everyMin(scdCb c) { mStack.add(c, SCD_MIN, SCD_MIN); }
@@ -85,6 +85,20 @@ namespace ah {
mTimestamp = ts;
}
+ bool resetEveryById(uint8_t id) {
+ sP *p = mStack.getFront();
+ while(NULL != p) {
+ if(p->id == id)
+ break;
+ p = mStack.get(p);
+ }
+ if(NULL != p) {
+ p->d.timeout = p->d.reload;
+ return true;
+ }
+ return false;
+ }
+
uint32_t getUptime(void) {
return mUptime;
}
@@ -135,7 +149,7 @@ namespace ah {
}
}
- llist<25, scdEvry_s, scdCb, uint32_t, uint32_t> mStack;
+ llist<20, scdEvry_s, scdCb, uint32_t, uint32_t> mStack;
llist<10, scdAt_s, scdCb, uint32_t> mStackAt;
uint32_t mMillis, mPrevMillis, mDiff;
uint32_t mUptime;
diff --git a/src/web/html/api.js b/src/web/html/api.js
index 0606dfa8..cfbddce5 100644
--- a/src/web/html/api.js
+++ b/src/web/html/api.js
@@ -129,7 +129,7 @@ function lbl(htmlfor, val, cl=null, id=null) {
return e;
}
-function inp(name, val, max=32, cl=["text"], id=null, type=null) {
+function inp(name, val, max=32, cl=["text"], id=null, type=null, pattern=null, title=null) {
e = document.createElement('input');
e.classList.add(...cl);
e.name = name;
@@ -137,6 +137,8 @@ function inp(name, val, max=32, cl=["text"], id=null, type=null) {
if(null != max) e.maxLength = max;
if(null != id) e.id = id;
if(null != type) e.type = type;
+ if(null != pattern) e.pattern = pattern;
+ if(null != title) e.title = title;
return e;
}
diff --git a/src/web/html/serial.html b/src/web/html/serial.html
index a102b58c..8b2d292c 100644
--- a/src/web/html/serial.html
+++ b/src/web/html/serial.html
@@ -25,21 +25,11 @@
Uptime:
-
-
-
-
-