mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-31 01:36:11 +02:00
fix blue LED lights up all the time #672
added an instant start communication (once NTP is synced)
This commit is contained in:
parent
e03464dabc
commit
a157f2b97b
7 changed files with 30 additions and 17 deletions
|
@ -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()`
|
||||
|
||||
|
|
31
src/app.cpp
31
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;
|
||||
|
||||
|
|
|
@ -256,6 +256,7 @@ class app : public IApp, public ah::Scheduler {
|
|||
settings_t *mConfig;
|
||||
|
||||
uint8_t mSendLastIvId;
|
||||
bool mSendFirst;
|
||||
|
||||
statistics_t mStat;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 5
|
||||
#define VERSION_PATCH 83
|
||||
#define VERSION_PATCH 84
|
||||
|
||||
//-------------------------------------
|
||||
typedef struct {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<uint8_t*>(&invId));
|
||||
mNrf24.startWrite(mTxBuf, len, false); // false = request ACK response
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue