mirror of
https://github.com/lumapu/ahoy.git
synced 2025-08-06 09:58:23 +02:00
review MI next cmd queuing
- still sends out to much messages and shows some strange behaviour
This commit is contained in:
parent
810afaac8b
commit
46b37cadde
2 changed files with 19 additions and 3 deletions
|
@ -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<void(bool valid, const queue_s *q)> cb) {
|
||||
if(mRdPtr == mWrPtr) {
|
||||
cb(false, &mQueue[mRdPtr]); // empty
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue