diff --git a/src/CHANGES.md b/src/CHANGES.md index 0c096321..75ab7826 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,10 @@ (starting from release version `0.5.66`) +## 0.5.84 +* fix blue LED lights up all the time #672 +* added an instant start communication (once NTP is synced) + ## 0.5.83 * fix MQTT publishing, `callback` was set but reset by following `setup()` diff --git a/src/app.cpp b/src/app.cpp index 92512108..cdaa7661 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -164,7 +164,8 @@ void app::tickNtpUpdate(void) { mMqttReconnect = false; } - everyMin(std::bind(&app::tickMinute, this), "tMin"); + if(mConfig->inst.rstValsNotAvail) + everyMin(std::bind(&app::tickMinute, this), "tMin"); if(mConfig->inst.rstYieldMidNight) { uint32_t midTrig = mTimestamp - ((mTimestamp - 1) % 86400) + 86400; // next midnight onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi"); @@ -176,6 +177,12 @@ void app::tickNtpUpdate(void) { mCalculatedTimezoneOffset = (int8_t)((mConfig->sun.lon >= 0 ? mConfig->sun.lon + 7.5 : mConfig->sun.lon - 7.5) / 15) * 3600; tickCalcSunrise(); } + + // immediately start communicating + if(isOK && mSendFirst) { + mSendFirst = false; + once(std::bind(&app::tickSend, this), 2, "senOn"); + } } once(std::bind(&app::tickNtpUpdate, this), nxtTrig, "ntp"); } @@ -246,17 +253,17 @@ void app::tickComm(void) { //----------------------------------------------------------------------------- void app::tickMinute(void) { - if(mConfig->inst.rstValsNotAvail) { - Inverter<> *iv; - // set values to zero, except yields - for (uint8_t id = 0; id < mSys.getNumInverters(); id++) { - iv = mSys.getInverterByPos(id); - if (NULL == iv) - continue; // skip to next inverter + // only triggered if 'reset values on no avail is enabled' - if(!iv->isAvailable(mTimestamp) && !iv->isProducing(mTimestamp) && iv->config->enabled) - mPayload.zeroInverterValues(iv); - } + Inverter<> *iv; + // set values to zero, except yields + for (uint8_t id = 0; id < mSys.getNumInverters(); id++) { + iv = mSys.getInverterByPos(id); + if (NULL == iv) + continue; // skip to next inverter + + if(!iv->isAvailable(mTimestamp) && !iv->isProducing(mTimestamp) && iv->config->enabled) + mPayload.zeroInverterValues(iv); } } @@ -325,6 +332,8 @@ void app::resetSystem(void) { mTimestamp = 1; #endif + mSendFirst = true; + mSunrise = 0; mSunset = 0; diff --git a/src/app.h b/src/app.h index 47990928..c0fefcf1 100644 --- a/src/app.h +++ b/src/app.h @@ -256,6 +256,7 @@ class app : public IApp, public ah::Scheduler { settings_t *mConfig; uint8_t mSendLastIvId; + bool mSendFirst; statistics_t mStat; diff --git a/src/defines.h b/src/defines.h index ddf017e9..58ad1674 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 83 +#define VERSION_PATCH 84 //------------------------------------- typedef struct { diff --git a/src/hm/hmPayload.h b/src/hm/hmPayload.h index d59ca5dd..b0f256bc 100644 --- a/src/hm/hmPayload.h +++ b/src/hm/hmPayload.h @@ -93,7 +93,6 @@ class HmPayload { case FLD_ACT_ACTIVE_PWR_LIMIT: fld++; continue; - break; } pos = iv->getPosByChFld(ch, fld, rec); iv->setValue(pos, rec, 0.0f); diff --git a/src/hm/hmRadio.h b/src/hm/hmRadio.h index 203e3b7f..80738e48 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/hmRadio.h @@ -118,6 +118,8 @@ class HmRadio { DPRINTLN(DBG_INFO, String(rf24AmpPowerNames[ampPwr])); mNrf24.setPALevel(ampPwr & 0x03); + mNrf24.startListening(); + if(mNrf24.isChipConnected()) { DPRINTLN(DBG_INFO, F("Radio Config:")); mNrf24.printPrettyDetails(); @@ -138,7 +140,6 @@ class HmRadio { // start listening on the default RX channel mRxChIdx = 0; mNrf24.setChannel(mRfChLst[mRxChIdx]); - mNrf24.startListening(); //uint32_t debug_ms = millis(); uint16_t cnt = 300; // that is 60 times 5 channels @@ -160,7 +161,6 @@ class HmRadio { } // not finished but time is over //DBGPRINTLN("RX not finished: 300 time used: " + String(millis()-debug_ms)+ " ms"); - mNrf24.stopListening(); return true; } @@ -299,6 +299,7 @@ class HmRadio { dumpBuf(mTxBuf, len); } + mNrf24.stopListening(); mNrf24.setChannel(mRfChLst[mTxChIdx]); mNrf24.openWritingPipe(reinterpret_cast(&invId)); mNrf24.startWrite(mTxBuf, len, false); // false = request ACK response diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 47b62353..94524faf 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -385,8 +385,7 @@ class PubMqtt { /*char out[128]; serializeJson(root, out, 128); DPRINTLN(DBG_INFO, "json: " + String(out));*/ - if(NULL != mSubscriptionCb) - (mSubscriptionCb)(root); + (mSubscriptionCb)(root); mRxCnt++; }