From 41ade24538c12031f029f6fb382e9de81a92c864 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 1 Oct 2023 12:36:18 +0200 Subject: [PATCH] 0.7.62 * add timeout before payload is tried to process (necessary for HMS/HMT) --- src/CHANGES.md | 1 + src/app.cpp | 7 ++----- src/app.h | 3 --- src/hm/hmInverter.h | 1 + src/hm/hmPayload.h | 5 +++++ 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 0f2bdda4c..893b8a3ac 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,7 @@ ## 0.7.62 - 2023-10-01 * fix communication to inverters #1198 +* add timeout before payload is tried to process (necessary for HMS/HMT) ## 0.7.61 - 2023-10-01 * merged `hmPayload` and `hmsPayload` into single class diff --git a/src/app.cpp b/src/app.cpp index 14c22e183..762c0c34e 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -133,10 +133,10 @@ void app::loop(void) { DBGPRINT(F("dBm | ")); ah::dumpBuf(p->packet, p->len); } - mNrfStat.frmCnt++; Inverter<> *iv = mSys.findInverter(&p->packet[1]); if (NULL != iv) { + iv->radioStatistics.frmCnt++; if (IV_MI == iv->ivGen) mMiPayload.add(iv, p); else @@ -160,10 +160,10 @@ void app::loop(void) { DBGPRINT(F("dBm | ")); ah::dumpBuf(p->packet, p->len); } - mCmtStat.frmCnt++; Inverter<> *iv = mSys.findInverter(&p->packet[1]); if(NULL != iv) { + iv->radioStatistics.frmCnt++; if((iv->ivGen == IV_HMS) || (iv->ivGen == IV_HMT)) mPayload.add(iv, p); } @@ -515,9 +515,6 @@ void app::resetSystem(void) { mSaveReboot = false; mNetworkConnected = false; - - memset(&mNrfStat, 0, sizeof(statistics_t)); - memset(&mCmtStat, 0, sizeof(statistics_t)); } //----------------------------------------------------------------------------- diff --git a/src/app.h b/src/app.h index 72fdbf449..ac516302a 100644 --- a/src/app.h +++ b/src/app.h @@ -334,9 +334,6 @@ class app : public IApp, public ah::Scheduler { bool mNetworkConnected; - statistics_t mNrfStat; - statistics_t mCmtStat; - // mqtt PubMqttType mMqtt; bool mMqttReconnect; diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 17ad6cc5d..238e80e4b 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -173,6 +173,7 @@ class Inverter { alarmCnt = 0; alarmLastId = 0; rssi = -127; + memset(&radioStatistics, 0, sizeof(statistics_t)); } ~Inverter() { diff --git a/src/hm/hmPayload.h b/src/hm/hmPayload.h index 1f6e04681..5689af9d3 100644 --- a/src/hm/hmPayload.h +++ b/src/hm/hmPayload.h @@ -31,6 +31,7 @@ typedef struct { bool requested; bool gotFragment; bool rxTmo; + uint32_t sendMillis; } invPayload_t; @@ -247,6 +248,9 @@ class HmPayload { continue; // skip to next inverter } + if((mPayload[iv->id].sendMillis + 500) > millis()) + return; // to fast, wait until packets are received! + if (!mPayload[iv->id].complete) { bool crcPass, pyldComplete, fastNext; @@ -469,6 +473,7 @@ class HmPayload { mPayload[id].requested = false; mPayload[id].ts = *mTimestamp; mPayload[id].rxTmo = setTxTmo; // design: don't start with complete retransmit + mPayload[id].sendMillis = millis(); } IApp *mApp;