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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue