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);
|
inc(&mWrPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void chgCmd(Inverter<> *iv, uint8_t cmd, bool delOnPop = true) {
|
||||||
|
mQueue[mWrPtr] = queue_s(iv, cmd, delOnPop, false);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct queue_s {
|
struct queue_s {
|
||||||
Inverter<> *iv;
|
Inverter<> *iv;
|
||||||
|
@ -37,6 +41,7 @@ class CommQueue {
|
||||||
uint32_t ts;
|
uint32_t ts;
|
||||||
bool delOnPop;
|
bool delOnPop;
|
||||||
bool isDevControl;
|
bool isDevControl;
|
||||||
|
bool firstTry;
|
||||||
queue_s() {}
|
queue_s() {}
|
||||||
queue_s(Inverter<> *i, uint8_t c, bool d, bool dev) :
|
queue_s(Inverter<> *i, uint8_t c, bool d, bool dev) :
|
||||||
iv(i), cmd(c), attempts(5), ts(0), delOnPop(d), isDevControl(dev) {}
|
iv(i), cmd(c), attempts(5), ts(0), delOnPop(d), isDevControl(dev) {}
|
||||||
|
@ -45,6 +50,10 @@ class CommQueue {
|
||||||
protected:
|
protected:
|
||||||
void add(queue_s q) {
|
void add(queue_s q) {
|
||||||
mQueue[mWrPtr] = 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);
|
inc(&mWrPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +68,11 @@ class CommQueue {
|
||||||
inc(&mWrPtr);
|
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) {
|
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
|
||||||
|
|
|
@ -541,10 +541,10 @@ class Communication : public CommQueue<> {
|
||||||
FCNT = (uint8_t)(p->packet[26]);
|
FCNT = (uint8_t)(p->packet[26]);
|
||||||
FCODE = (uint8_t)(p->packet[27]);
|
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) ) {
|
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].txCmd++;
|
||||||
//mPayload[iv->id].retransmits = 0; // reserve retransmissions for each response
|
//mPayload[iv->id].retransmits = 0; // reserve retransmissions for each response
|
||||||
//mPayload[iv->id].complete = false;
|
//mPayload[iv->id].complete = false;
|
||||||
|
@ -553,7 +553,7 @@ class Communication : public CommQueue<> {
|
||||||
miComplete(q->iv);
|
miComplete(q->iv);
|
||||||
}
|
}
|
||||||
} else if((p->packet[0] == (MI_REQ_CH1 + ALL_FRAMES)) && (q->iv->type == INV_TYPE_2CH)) {
|
} 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);
|
miNextRequest(MI_REQ_CH2, q);
|
||||||
} else { // first data msg for 1ch, 2nd for 2ch
|
} else { // first data msg for 1ch, 2nd for 2ch
|
||||||
miComplete(q->iv);
|
miComplete(q->iv);
|
||||||
|
@ -573,6 +573,8 @@ class Communication : public CommQueue<> {
|
||||||
q->iv->radio->sendCmdPacket(q->iv, cmd, 0x00, true);
|
q->iv->radio->sendCmdPacket(q->iv, cmd, 0x00, true);
|
||||||
q->iv->radioStatistics.retransmits++;
|
q->iv->radioStatistics.retransmits++;
|
||||||
mWaitTimeout = millis() + MI_TIMEOUT;
|
mWaitTimeout = millis() + MI_TIMEOUT;
|
||||||
|
//chgCmd(Inverter<> *iv, uint8_t cmd, bool delOnPop = true)
|
||||||
|
chgCmd(cmd);
|
||||||
mState = States::WAIT;
|
mState = States::WAIT;
|
||||||
} else {
|
} else {
|
||||||
add(q, true);
|
add(q, true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue