diff --git a/src/hm/CommQueue.h b/src/hm/CommQueue.h index ae947504..1acda1a1 100644 --- a/src/hm/CommQueue.h +++ b/src/hm/CommQueue.h @@ -29,6 +29,10 @@ class CommQueue { inc(&mWrPtr); } + void chgCmd(Inverter<> *iv, uint8_t cmd, bool delOnPop = true) { + mQueue[mWrPtr] = queue_s(iv, cmd, delOnPop, false); + } + protected: struct queue_s { Inverter<> *iv; @@ -37,6 +41,7 @@ class CommQueue { uint32_t ts; bool delOnPop; bool isDevControl; + bool firstTry; queue_s() {} queue_s(Inverter<> *i, uint8_t c, bool d, bool dev) : iv(i), cmd(c), attempts(5), ts(0), delOnPop(d), isDevControl(dev) {} @@ -45,6 +50,10 @@ class CommQueue { protected: void add(queue_s q) { mQueue[mWrPtr] = q; + /*mQueue[mRdPtr].firstTry = false; + if((IV_HM == mQueue[mRdPtr].iv->ivGen) || (IV_MI == mQueue[mRdPtr].iv->ivGen)) { + mQueue[mRdPtr].firstTry = ((mQueue[mRdPtr].iv->isAvailable()) || (millis() < 120000)); + }*/ inc(&mWrPtr); } @@ -59,6 +68,11 @@ class CommQueue { inc(&mWrPtr); } + void chgCmd(uint8_t cmd) { + mQueue[mRdPtr].cmd = cmd; + mQueue[mRdPtr].isDevControl = false; + } + void get(std::function cb) { if(mRdPtr == mWrPtr) { cb(false, &mQueue[mRdPtr]); // empty diff --git a/src/hm/Communication.h b/src/hm/Communication.h index 1a23ca07..aaf52a64 100644 --- a/src/hm/Communication.h +++ b/src/hm/Communication.h @@ -541,10 +541,10 @@ class Communication : public CommQueue<> { FCNT = (uint8_t)(p->packet[26]); FCODE = (uint8_t)(p->packet[27]); }*/ - miStsConsolidate(q, datachan, rec, p->packet[23], p->packet[24]); + miStsConsolidate(q, datachan, rec, p->packet[23], p->packet[24]); if (p->packet[0] < (0x39 + ALL_FRAMES) ) { - addImportant(q->iv, (q->cmd + 1)); + //addImportant(q->iv, (q->cmd + 1)); //mPayload[iv->id].txCmd++; //mPayload[iv->id].retransmits = 0; // reserve retransmissions for each response //mPayload[iv->id].complete = false; @@ -553,7 +553,7 @@ class Communication : public CommQueue<> { miComplete(q->iv); } } else if((p->packet[0] == (MI_REQ_CH1 + ALL_FRAMES)) && (q->iv->type == INV_TYPE_2CH)) { - addImportant(q->iv, MI_REQ_CH2); + //addImportant(q->iv, MI_REQ_CH2); miNextRequest(MI_REQ_CH2, q); } else { // first data msg for 1ch, 2nd for 2ch miComplete(q->iv); @@ -573,6 +573,8 @@ class Communication : public CommQueue<> { q->iv->radio->sendCmdPacket(q->iv, cmd, 0x00, true); q->iv->radioStatistics.retransmits++; mWaitTimeout = millis() + MI_TIMEOUT; + //chgCmd(Inverter<> *iv, uint8_t cmd, bool delOnPop = true) + chgCmd(cmd); mState = States::WAIT; } else { add(q, true);