Browse Source

some improvements

pull/1219/head
lumapu 12 months ago
parent
commit
96f181c662
  1. 20
      src/app.cpp
  2. 7
      src/hm/CommQueue.h
  3. 35
      src/hm/Communication.h
  4. 6
      src/hm/hmInverter.h

20
src/app.cpp

@ -413,13 +413,15 @@ void app::tickSend(void) {
for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
Inverter<> *iv = mSys.getInverterByPos(i);
if(NULL != iv) {
iv->tickSend([this, iv](uint8_t cmd, bool isDevControl) {
if(isDevControl)
mCommunication.addImportant(iv, cmd);
else
mCommunication.add(iv, cmd);
});
};
if(iv->config->enabled) {
iv->tickSend([this, iv](uint8_t cmd, bool isDevControl) {
if(isDevControl)
mCommunication.addImportant(iv, cmd);
else
mCommunication.add(iv, cmd);
});
}
}
}
/*if(mConfig->nrf.enabled) {
@ -468,9 +470,9 @@ void app::tickSend(void) {
if (mConfig->serial.debug)
DPRINTLN(DBG_WARN, F("Time not set or it is night time, therefore no communication to the inverter!"));
}
yield();
yield();*/
updateLed();*/
updateLed();
}
//-----------------------------------------------------------------------------

7
src/hm/CommQueue.h

@ -44,6 +44,13 @@ class CommQueue {
inc(&mWrPtr);
}
void add(const queue_s *q, bool rstAttempts = false) {
mQueue[mWrPtr] = *q;
if(rstAttempts)
mQueue[mWrPtr].attempts = 5;
inc(&mWrPtr);
}
void get(std::function<void(bool valid, const queue_s *q)> cb) {
if(mRdPtr == mWrPtr) {
cb(false, &mQueue[mRdPtr]); // empty

35
src/hm/Communication.h

@ -112,7 +112,8 @@ class Communication : public CommQueue<> {
parseDevCtrl(p, q);
cmdDone(true); // remove done request
}
}
} else
DPRINTLN(DBG_WARN, F("Inverter serial does not match"));
q->iv->radio->mBufCtrl.pop();
yield();
@ -126,7 +127,7 @@ class Communication : public CommQueue<> {
setAttempt();
DPRINT_IVID(DBG_WARN, q->iv->id);
DBGPRINT(F("last frame missing: request retransmit ("));
DBGPRINT(F("frame missing: request retransmit ("));
DBGPRINT(String(q->attempts));
DBGPRINTLN(F(" attempts left)"));
@ -136,11 +137,17 @@ class Communication : public CommQueue<> {
break;
}
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (ALL_FRAMES + i), true);
q->iv->radioStatistics.retransmits++;
mWaitTimeout = millis() + 500;
mState = States::WAIT;
break;
if(q->attempts) {
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (ALL_FRAMES + i), true);
q->iv->radioStatistics.retransmits++;
mWaitTimeout = millis() + 500;
mState = States::WAIT;
} else {
add(q, true);
cmdDone(q);
mState = States::RESET;
}
return;
}
for(uint8_t i = 0; i < mMaxFrameId; i++) {
@ -154,10 +161,16 @@ class Communication : public CommQueue<> {
DBGPRINT(String(q->attempts));
DBGPRINTLN(F(" attempts left)"));
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (ALL_FRAMES + i), true);
q->iv->radioStatistics.retransmits++;
mWaitTimeout = millis() + 500;
mState = States::WAIT;
if(q->attempts) {
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (ALL_FRAMES + i), true);
q->iv->radioStatistics.retransmits++;
mWaitTimeout = millis() + 500;
mState = States::WAIT;
} else {
add(q, true);
cmdDone(q);
mState = States::RESET;
}
return;
}
}

6
src/hm/hmInverter.h

@ -617,9 +617,9 @@ class Inverter {
uint32_t startTimeOffset = 0, endTimeOffset = 0;
uint32_t start, endTime;
if (((wCode >> 13) & 0x01) == 1) // check if is AM or PM
startTimeOffset = 12 * 60 * 60;
if (((wCode >> 12) & 0x01) == 1) // check if is AM or PM
// check if is AM or PM
startTimeOffset = ((wCode >> 13) & 0x01) * 12 * 60 * 60;
if (((wCode >> 12) & 0x03) != 0)
endTimeOffset = 12 * 60 * 60;
start = (((uint16_t)pyld[startOff + 4] << 8) | ((uint16_t)pyld[startOff + 5])) + startTimeOffset;

Loading…
Cancel
Save