From aa6a022214a5a83e33c3f0d7b2dc1bee8301ba33 Mon Sep 17 00:00:00 2001 From: Patrick Amrhein Date: Sat, 6 Jan 2024 19:45:18 +0100 Subject: [PATCH] Add defines for Retry ATTEMPS --- src/hm/CommQueue.h | 18 ++++++++++++++---- src/hm/Communication.h | 12 ++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/hm/CommQueue.h b/src/hm/CommQueue.h index bb815a7e8..eb770bb05 100644 --- a/src/hm/CommQueue.h +++ b/src/hm/CommQueue.h @@ -11,6 +11,10 @@ #include "hmInverter.h" #include "../utils/dbg.h" +#define DEFAULT_ATTEMPS 10 +#define MORE_ATTEMPS_ALARMDATA 15 +#define MORE_ATTEMPS_GRIDONPROFILEPARA 15 + template class CommQueue { public: @@ -44,11 +48,12 @@ class CommQueue { Inverter<> *iv; uint8_t cmd; uint8_t attempts; + uint8_t attemptsMax; uint32_t ts; bool isDevControl; queue_s() {} queue_s(Inverter<> *i, uint8_t c, bool dev) : - iv(i), cmd(c), attempts(5), ts(0), isDevControl(dev) {} + iv(i), cmd(c), attempts(DEFAULT_ATTEMPS), attemptsMax(DEFAULT_ATTEMPS), ts(0), isDevControl(dev) {} }; protected: @@ -59,8 +64,10 @@ class CommQueue { void add(const queue_s *q, bool rstAttempts = false) { mQueue[mWrPtr] = *q; - if(rstAttempts) - mQueue[mWrPtr].attempts = 5; + if(rstAttempts) { + mQueue[mWrPtr].attempts = DEFAULT_ATTEMPS; + mQueue[mWrPtr].attemptsMax = DEFAULT_ATTEMPS; + } inc(&mWrPtr); } @@ -79,7 +86,8 @@ class CommQueue { void cmdDone(bool keep = false) { if(keep) { - mQueue[mRdPtr].attempts = 5; + mQueue[mRdPtr].attempts = DEFAULT_ATTEMPS; + mQueue[mRdPtr].attemptsMax = DEFAULT_ATTEMPS; add(mQueue[mRdPtr]); // add to the end again } inc(&mRdPtr); @@ -96,6 +104,8 @@ class CommQueue { void incrAttempt(uint8_t attempts = 1) { mQueue[mRdPtr].attempts += attempts; + if (mQueue[mRdPtr].attempts > mQueue[mRdPtr].attemptsMax) + mQueue[mRdPtr].attemptsMax = mQueue[mRdPtr].attempts; } void inc(uint8_t *ptr) { diff --git a/src/hm/Communication.h b/src/hm/Communication.h index f69d19c7b..3c7c82a59 100644 --- a/src/hm/Communication.h +++ b/src/hm/Communication.h @@ -118,8 +118,8 @@ class Communication : public CommQueue<> { mIsRetransmit = false; setAttempt(); if((q->cmd == AlarmData) || (q->cmd == GridOnProFilePara)) - incrAttempt(15); - + incrAttempt(q->cmd == AlarmData? MORE_ATTEMPS_ALARMDATA : MORE_ATTEMPS_GRIDONPROFILEPARA); +/// statt 5:3 mState = States::WAIT; break; @@ -194,7 +194,7 @@ class Communication : public CommQueue<> { return; } } else { - mHeu.evalTxChQuality(q->iv, true, (4 - q->attempts), q->iv->curFrmCnt); + mHeu.evalTxChQuality(q->iv, true, (q->attemptsMax - 1 - q->attempts), q->iv->curFrmCnt); if(((q->cmd == 0x39) && (q->iv->type == INV_TYPE_4CH)) || ((q->cmd == MI_REQ_CH2) && (q->iv->type == INV_TYPE_2CH)) || ((q->cmd == MI_REQ_CH1) && (q->iv->type == INV_TYPE_1CH))) { @@ -529,7 +529,7 @@ class Communication : public CommQueue<> { private: void closeRequest(const queue_s *q, bool crcPass) { - mHeu.evalTxChQuality(q->iv, crcPass, (4 - q->attempts), q->iv->curFrmCnt); + mHeu.evalTxChQuality(q->iv, crcPass, (q->attemptsMax - 1 - q->attempts), q->iv->curFrmCnt); if(crcPass) q->iv->radioStatistics.rxSuccess++; else if(q->iv->mGotFragment) @@ -730,7 +730,7 @@ class Communication : public CommQueue<> { miStsConsolidate(q, datachan, rec, p->packet[23], p->packet[24]); if (p->packet[0] < (0x39 + ALL_FRAMES) ) { - mHeu.evalTxChQuality(q->iv, true, (4 - q->attempts), 1); + mHeu.evalTxChQuality(q->iv, true, (q->attemptsMax - 1 - q->attempts), 1); miNextRequest((p->packet[0] - ALL_FRAMES + 1), q); } else { q->iv->miMultiParts = 7; // indicate we are ready @@ -739,7 +739,7 @@ class Communication : public CommQueue<> { } else if((p->packet[0] == (MI_REQ_CH1 + ALL_FRAMES)) && (q->iv->type == INV_TYPE_2CH)) { //addImportant(q->iv, MI_REQ_CH2); miNextRequest(MI_REQ_CH2, q); - mHeu.evalTxChQuality(q->iv, true, (4 - q->attempts), q->iv->curFrmCnt); + mHeu.evalTxChQuality(q->iv, true, (q->attemptsMax - 1 - q->attempts), q->iv->curFrmCnt); //use also miMultiParts here for better statistics? //mHeu.setGotFragment(q->iv); } else { // first data msg for 1ch, 2nd for 2ch