mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-31 09:46:12 +02:00
some improvements
This commit is contained in:
parent
bf772756ed
commit
96f181c662
4 changed files with 45 additions and 23 deletions
20
src/app.cpp
20
src/app.cpp
|
@ -413,13 +413,15 @@ void app::tickSend(void) {
|
||||||
for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
|
for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
|
||||||
Inverter<> *iv = mSys.getInverterByPos(i);
|
Inverter<> *iv = mSys.getInverterByPos(i);
|
||||||
if(NULL != iv) {
|
if(NULL != iv) {
|
||||||
iv->tickSend([this, iv](uint8_t cmd, bool isDevControl) {
|
if(iv->config->enabled) {
|
||||||
if(isDevControl)
|
iv->tickSend([this, iv](uint8_t cmd, bool isDevControl) {
|
||||||
mCommunication.addImportant(iv, cmd);
|
if(isDevControl)
|
||||||
else
|
mCommunication.addImportant(iv, cmd);
|
||||||
mCommunication.add(iv, cmd);
|
else
|
||||||
});
|
mCommunication.add(iv, cmd);
|
||||||
};
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(mConfig->nrf.enabled) {
|
/*if(mConfig->nrf.enabled) {
|
||||||
|
@ -468,9 +470,9 @@ void app::tickSend(void) {
|
||||||
if (mConfig->serial.debug)
|
if (mConfig->serial.debug)
|
||||||
DPRINTLN(DBG_WARN, F("Time not set or it is night time, therefore no communication to the inverter!"));
|
DPRINTLN(DBG_WARN, F("Time not set or it is night time, therefore no communication to the inverter!"));
|
||||||
}
|
}
|
||||||
yield();
|
yield();*/
|
||||||
|
|
||||||
updateLed();*/
|
updateLed();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -44,6 +44,13 @@ class CommQueue {
|
||||||
inc(&mWrPtr);
|
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) {
|
void get(std::function<void(bool valid, const queue_s *q)> cb) {
|
||||||
if(mRdPtr == mWrPtr) {
|
if(mRdPtr == mWrPtr) {
|
||||||
cb(false, &mQueue[mRdPtr]); // empty
|
cb(false, &mQueue[mRdPtr]); // empty
|
||||||
|
|
|
@ -112,7 +112,8 @@ class Communication : public CommQueue<> {
|
||||||
parseDevCtrl(p, q);
|
parseDevCtrl(p, q);
|
||||||
cmdDone(true); // remove done request
|
cmdDone(true); // remove done request
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
DPRINTLN(DBG_WARN, F("Inverter serial does not match"));
|
||||||
|
|
||||||
q->iv->radio->mBufCtrl.pop();
|
q->iv->radio->mBufCtrl.pop();
|
||||||
yield();
|
yield();
|
||||||
|
@ -126,7 +127,7 @@ class Communication : public CommQueue<> {
|
||||||
setAttempt();
|
setAttempt();
|
||||||
|
|
||||||
DPRINT_IVID(DBG_WARN, q->iv->id);
|
DPRINT_IVID(DBG_WARN, q->iv->id);
|
||||||
DBGPRINT(F("last frame missing: request retransmit ("));
|
DBGPRINT(F("frame missing: request retransmit ("));
|
||||||
DBGPRINT(String(q->attempts));
|
DBGPRINT(String(q->attempts));
|
||||||
DBGPRINTLN(F(" attempts left)"));
|
DBGPRINTLN(F(" attempts left)"));
|
||||||
|
|
||||||
|
@ -136,11 +137,17 @@ class Communication : public CommQueue<> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (ALL_FRAMES + i), true);
|
if(q->attempts) {
|
||||||
q->iv->radioStatistics.retransmits++;
|
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (ALL_FRAMES + i), true);
|
||||||
mWaitTimeout = millis() + 500;
|
q->iv->radioStatistics.retransmits++;
|
||||||
mState = States::WAIT;
|
mWaitTimeout = millis() + 500;
|
||||||
break;
|
mState = States::WAIT;
|
||||||
|
} else {
|
||||||
|
add(q, true);
|
||||||
|
cmdDone(q);
|
||||||
|
mState = States::RESET;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint8_t i = 0; i < mMaxFrameId; i++) {
|
for(uint8_t i = 0; i < mMaxFrameId; i++) {
|
||||||
|
@ -154,10 +161,16 @@ class Communication : public CommQueue<> {
|
||||||
DBGPRINT(String(q->attempts));
|
DBGPRINT(String(q->attempts));
|
||||||
DBGPRINTLN(F(" attempts left)"));
|
DBGPRINTLN(F(" attempts left)"));
|
||||||
|
|
||||||
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (ALL_FRAMES + i), true);
|
if(q->attempts) {
|
||||||
q->iv->radioStatistics.retransmits++;
|
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (ALL_FRAMES + i), true);
|
||||||
mWaitTimeout = millis() + 500;
|
q->iv->radioStatistics.retransmits++;
|
||||||
mState = States::WAIT;
|
mWaitTimeout = millis() + 500;
|
||||||
|
mState = States::WAIT;
|
||||||
|
} else {
|
||||||
|
add(q, true);
|
||||||
|
cmdDone(q);
|
||||||
|
mState = States::RESET;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -617,9 +617,9 @@ class Inverter {
|
||||||
uint32_t startTimeOffset = 0, endTimeOffset = 0;
|
uint32_t startTimeOffset = 0, endTimeOffset = 0;
|
||||||
uint32_t start, endTime;
|
uint32_t start, endTime;
|
||||||
|
|
||||||
if (((wCode >> 13) & 0x01) == 1) // check if is AM or PM
|
// check if is AM or PM
|
||||||
startTimeOffset = 12 * 60 * 60;
|
startTimeOffset = ((wCode >> 13) & 0x01) * 12 * 60 * 60;
|
||||||
if (((wCode >> 12) & 0x01) == 1) // check if is AM or PM
|
if (((wCode >> 12) & 0x03) != 0)
|
||||||
endTimeOffset = 12 * 60 * 60;
|
endTimeOffset = 12 * 60 * 60;
|
||||||
|
|
||||||
start = (((uint16_t)pyld[startOff + 4] << 8) | ((uint16_t)pyld[startOff + 5])) + startTimeOffset;
|
start = (((uint16_t)pyld[startOff + 4] << 8) | ((uint16_t)pyld[startOff + 5])) + startTimeOffset;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue