diff --git a/src/defines.h b/src/defines.h index 3a85392f..4c4a77d8 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 2716 +#define VERSION_PATCH 2720 //------------------------------------- typedef struct { diff --git a/src/hm/Communication.h b/src/hm/Communication.h index b5b1aa66..8b6550cc 100644 --- a/src/hm/Communication.h +++ b/src/hm/Communication.h @@ -488,8 +488,10 @@ class Communication : public CommQueue<> { record_t<> *rec = q->iv->getRecordStruct(q->cmd); if(NULL == rec) { if(GetLossRate == q->cmd) { - q->iv->parseGetLossRate(q->iv->id, mPayload, len); - closeRequest(q, true); + //q->iv->parseGetLossRate(q->iv->id, mPayload, len); + q->iv->parseGetLossRate(mPayload, len); + //closeRequest(q, true); + return; } else { DPRINTLN(DBG_ERROR, F("record is NULL!")); closeRequest(q, false); diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 0a369802..474d97bb 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -175,6 +175,10 @@ class Inverter { mIsSingleframeReq = false; radio = NULL; commEnabled = true; + mIvRxCnt = 0; + mIvTxCnt = 0; + mDtuRxCnt = 0; + mDtuTxCnt = 0; memset(&radioStatistics, 0, sizeof(statistics_t)); memset(heuristics.txRfQuality, -6, 5); @@ -601,18 +605,21 @@ class Inverter { memset(mLastYD, 0, sizeof(float) * 6); } - bool parseGetLossRate(uint8_t id, uint8_t pyld[], uint8_t len) { + //bool parseGetLossRate(uint8_t id, uint8_t pyld[], uint8_t len) { + bool parseGetLossRate(uint8_t pyld[], uint8_t len) { if (len == HMGETLOSSRATE_PAYLOAD_LEN) { uint16_t rxCnt = (pyld[0] << 8) + pyld[1]; uint16_t txCnt = (pyld[2] << 8) + pyld[3]; if (mIvRxCnt || mIvTxCnt) { // there was successful GetLossRate in the past DPRINT_IVID(DBG_INFO, id); - DBGPRINTLN("Inv loss: " + String (mDtuTxCnt - (rxCnt - mIvRxCnt)) + " of " + + DBGPRINTLN("Inv loss: " + + String (mDtuTxCnt - (rxCnt - mIvRxCnt)) + " of " + String (mDtuTxCnt) + ", DTU loss: " + String (txCnt - mIvTxCnt - mDtuRxCnt) + " of " + String (txCnt - mIvTxCnt)); } + mIvRxCnt = rxCnt; mIvTxCnt = txCnt; mDtuRxCnt = 0; // start new interval diff --git a/src/hm/hmRadio.h b/src/hm/hmRadio.h index f8a1257d..e175c4dd 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/hmRadio.h @@ -130,10 +130,12 @@ class HmRadio : public Radio { //mRxChannels - 1; // //(mTxChIdx + mRxChannels) % RF_MAX_CHANNEL_ID; // start with a fixed offset bool switchch = true; + uint8_t looprounds = 0; while ((millis() - loopMillis) < mRxTmoOuterLoop) { while ((micros() - startMicros) < mRxTmoInnerLoop) { // listen (4088us or?) 5110us to each channel if (mIrqRcvd) { mIrqRcvd = false; + mLastIv->mRxChanSync = false; //reset if (getReceived()) { // everything received return; @@ -142,10 +144,22 @@ class HmRadio : public Radio { yield(); } // switch to next RX channel + bool chgchan = true; /*if (mLastIv->mRxChanSync) { - switchch = !switchch; - mRxChIdx = mLastIv->mRxChanIdx - switchch; + if (!looprounds) { + mRxChIdx = mLastIv->mRxChanIdx - switchch; + + } else if (++looprounds > 9) { + looprounds = 0; + switchch = !switchch; + mRxChIdx = mLastIv->mRxChanIdx - switchch; + if(switchch) + mLastIv->mRxChanSync = false; // we didn't receive st. timely on this channel + } else + chgchan = false; }*/ + + if(chgchan) { if(++mRxChIdx >= RF_CHANNELS) mRxChIdx = 0; @@ -157,6 +171,7 @@ class HmRadio : public Radio { mNrf24->setChannel(mRfChLst[mRxChIdx]); //mNrf24->setChannel(mRfChLst[nextRxCh]); + } startMicros = micros(); } // not finished but time is over