Browse Source

fix blue LED lights up all the time #672

added an instant start communication (once NTP is synced)
pull/698/head
lumapu 2 years ago
parent
commit
a157f2b97b
  1. 4
      src/CHANGES.md
  2. 13
      src/app.cpp
  3. 1
      src/app.h
  4. 2
      src/defines.h
  5. 1
      src/hm/hmPayload.h
  6. 5
      src/hm/hmRadio.h
  7. 1
      src/publisher/pubMqtt.h

4
src/CHANGES.md

@ -2,6 +2,10 @@
(starting from release version `0.5.66`) (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 ## 0.5.83
* fix MQTT publishing, `callback` was set but reset by following `setup()` * fix MQTT publishing, `callback` was set but reset by following `setup()`

13
src/app.cpp

@ -164,6 +164,7 @@ void app::tickNtpUpdate(void) {
mMqttReconnect = false; mMqttReconnect = false;
} }
if(mConfig->inst.rstValsNotAvail)
everyMin(std::bind(&app::tickMinute, this), "tMin"); everyMin(std::bind(&app::tickMinute, this), "tMin");
if(mConfig->inst.rstYieldMidNight) { if(mConfig->inst.rstYieldMidNight) {
uint32_t midTrig = mTimestamp - ((mTimestamp - 1) % 86400) + 86400; // next midnight uint32_t midTrig = mTimestamp - ((mTimestamp - 1) % 86400) + 86400; // next midnight
@ -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; mCalculatedTimezoneOffset = (int8_t)((mConfig->sun.lon >= 0 ? mConfig->sun.lon + 7.5 : mConfig->sun.lon - 7.5) / 15) * 3600;
tickCalcSunrise(); 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"); once(std::bind(&app::tickNtpUpdate, this), nxtTrig, "ntp");
} }
@ -246,7 +253,8 @@ void app::tickComm(void) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void app::tickMinute(void) { void app::tickMinute(void) {
if(mConfig->inst.rstValsNotAvail) { // only triggered if 'reset values on no avail is enabled'
Inverter<> *iv; Inverter<> *iv;
// set values to zero, except yields // set values to zero, except yields
for (uint8_t id = 0; id < mSys.getNumInverters(); id++) { for (uint8_t id = 0; id < mSys.getNumInverters(); id++) {
@ -257,7 +265,6 @@ void app::tickMinute(void) {
if(!iv->isAvailable(mTimestamp) && !iv->isProducing(mTimestamp) && iv->config->enabled) if(!iv->isAvailable(mTimestamp) && !iv->isProducing(mTimestamp) && iv->config->enabled)
mPayload.zeroInverterValues(iv); mPayload.zeroInverterValues(iv);
} }
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -325,6 +332,8 @@ void app::resetSystem(void) {
mTimestamp = 1; mTimestamp = 1;
#endif #endif
mSendFirst = true;
mSunrise = 0; mSunrise = 0;
mSunset = 0; mSunset = 0;

1
src/app.h

@ -256,6 +256,7 @@ class app : public IApp, public ah::Scheduler {
settings_t *mConfig; settings_t *mConfig;
uint8_t mSendLastIvId; uint8_t mSendLastIvId;
bool mSendFirst;
statistics_t mStat; statistics_t mStat;

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 83 #define VERSION_PATCH 84
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {

1
src/hm/hmPayload.h

@ -93,7 +93,6 @@ class HmPayload {
case FLD_ACT_ACTIVE_PWR_LIMIT: case FLD_ACT_ACTIVE_PWR_LIMIT:
fld++; fld++;
continue; continue;
break;
} }
pos = iv->getPosByChFld(ch, fld, rec); pos = iv->getPosByChFld(ch, fld, rec);
iv->setValue(pos, rec, 0.0f); iv->setValue(pos, rec, 0.0f);

5
src/hm/hmRadio.h

@ -118,6 +118,8 @@ class HmRadio {
DPRINTLN(DBG_INFO, String(rf24AmpPowerNames[ampPwr])); DPRINTLN(DBG_INFO, String(rf24AmpPowerNames[ampPwr]));
mNrf24.setPALevel(ampPwr & 0x03); mNrf24.setPALevel(ampPwr & 0x03);
mNrf24.startListening();
if(mNrf24.isChipConnected()) { if(mNrf24.isChipConnected()) {
DPRINTLN(DBG_INFO, F("Radio Config:")); DPRINTLN(DBG_INFO, F("Radio Config:"));
mNrf24.printPrettyDetails(); mNrf24.printPrettyDetails();
@ -138,7 +140,6 @@ class HmRadio {
// start listening on the default RX channel // start listening on the default RX channel
mRxChIdx = 0; mRxChIdx = 0;
mNrf24.setChannel(mRfChLst[mRxChIdx]); mNrf24.setChannel(mRfChLst[mRxChIdx]);
mNrf24.startListening();
//uint32_t debug_ms = millis(); //uint32_t debug_ms = millis();
uint16_t cnt = 300; // that is 60 times 5 channels uint16_t cnt = 300; // that is 60 times 5 channels
@ -160,7 +161,6 @@ class HmRadio {
} }
// not finished but time is over // not finished but time is over
//DBGPRINTLN("RX not finished: 300 time used: " + String(millis()-debug_ms)+ " ms"); //DBGPRINTLN("RX not finished: 300 time used: " + String(millis()-debug_ms)+ " ms");
mNrf24.stopListening();
return true; return true;
} }
@ -299,6 +299,7 @@ class HmRadio {
dumpBuf(mTxBuf, len); dumpBuf(mTxBuf, len);
} }
mNrf24.stopListening();
mNrf24.setChannel(mRfChLst[mTxChIdx]); mNrf24.setChannel(mRfChLst[mTxChIdx]);
mNrf24.openWritingPipe(reinterpret_cast<uint8_t*>(&invId)); mNrf24.openWritingPipe(reinterpret_cast<uint8_t*>(&invId));
mNrf24.startWrite(mTxBuf, len, false); // false = request ACK response mNrf24.startWrite(mTxBuf, len, false); // false = request ACK response

1
src/publisher/pubMqtt.h

@ -385,7 +385,6 @@ class PubMqtt {
/*char out[128]; /*char out[128];
serializeJson(root, out, 128); serializeJson(root, out, 128);
DPRINTLN(DBG_INFO, "json: " + String(out));*/ DPRINTLN(DBG_INFO, "json: " + String(out));*/
if(NULL != mSubscriptionCb)
(mSubscriptionCb)(root); (mSubscriptionCb)(root);
mRxCnt++; mRxCnt++;

Loading…
Cancel
Save