Browse Source

merged

pull/1234/head
lumapu 1 year ago
parent
commit
e8dbe02e4f
  1. 16
      src/hm/Communication.h
  2. 4
      src/hm/Heuristic.h

16
src/hm/Communication.h

@ -57,6 +57,7 @@ class Communication : public CommQueue<> {
mHeu.printStatus(q->iv);
mHeu.getTxCh(q->iv);
mGotFragment = false;
mFirstTry = mFirstTry ? false : ( (IV_HM == q->iv->ivGen) || (IV_MI == q->iv->ivGen) ) && (q->iv->isAvailable()); //) || (millis() < 120000));}
if(NULL == q->iv->radio)
cmdDone(true); // can't communicate while radio is not defined!
mState = States::START;
@ -98,7 +99,7 @@ class Communication : public CommQueue<> {
DBGPRINT(String(millis() - mWaitTimeout + timeout));
DBGPRINTLN(F("ms"));
if(!mGotFragment) {
if(!mGotFragment && !mFirstTry) {
q->iv->radioStatistics.rxFailNoAnser++; // got nothing
mHeu.setGotNothing(q->iv);
if((IV_HMS == q->iv->ivGen) || (IV_HMT == q->iv->ivGen)) {
@ -112,6 +113,7 @@ class Communication : public CommQueue<> {
}
mGotFragment = true;
mFirstTry = false; // for correct reset
States nextState = States::RESET;
while(!q->iv->radio->mBufCtrl.empty()) {
packet_t *p = &q->iv->radio->mBufCtrl.front();
@ -270,6 +272,7 @@ class Communication : public CommQueue<> {
record_t<> *rec = q->iv->getRecordStruct(RealTimeRunData_Debug); // choose the record structure
rec->ts = q->ts;
miStsConsolidate(q, ((p->packet[0] == 0x88) ? 1 : 2), rec, p->packet[10], p->packet[12], p->packet[9], p->packet[11]);
mHeu.setGotFragment(q->iv);
}
}
@ -512,6 +515,9 @@ class Communication : public CommQueue<> {
cmdDone(true);
mState = States::RESET;
q->iv->radioStatistics.rxSuccess++;
mHeu.setGotAll(q->iv);
} else {
mHeu.setGotFragment(q->iv);
}
/*if (mPayload[iv->id].multi_parts > 5) {
@ -572,12 +578,14 @@ class Communication : public CommQueue<> {
//mPayload[iv->id].retransmits = 0; // reserve retransmissions for each response
//mPayload[iv->id].complete = false;
miNextRequest((p->packet[0] - ALL_FRAMES + 1), q);
mHeu.setGotFragment(q->iv);
} else {
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);
miNextRequest(MI_REQ_CH2, q);
mHeu.setGotFragment(q->iv);
} else { // first data msg for 1ch, 2nd for 2ch
miComplete(q->iv);
}
@ -709,7 +717,12 @@ class Communication : public CommQueue<> {
// update status state-machine,
if (ac_pow)
iv->isProducing();
mHeu.setGotAll(iv);
cmdDone(true);
if(NULL != mCbPayload)
(mCbPayload)(RealTimeRunData_Debug, iv);
mState = States::RESET; // everything ok, next request
}
private:
@ -729,6 +742,7 @@ class Communication : public CommQueue<> {
uint32_t mWaitTimeout = 0;
std::array<frame_t, MAX_PAYLOAD_ENTRIES> mLocalBuf;
bool mGotFragment = false;
bool mFirstTry = false;
uint8_t mMaxFrameId;
uint8_t mPayload[MAX_BUFFER];
payloadListenerType mCbPayload = NULL;

4
src/hm/Heuristic.h

@ -48,8 +48,8 @@ class Heuristic {
}
void printStatus(Inverter<> *iv) {
DPRINT(DBG_INFO, F("Status:"));
DBGPRINT(F(" |"));
DPRINT_IVID(DBG_INFO, iv->id);
DBGPRINT(F("CH qualities:"));
for(uint8_t i = 0; i < RF_MAX_CHANNEL_ID; i++) {
DBGPRINT(F(" "));
DBGPRINT(String(iv->txRfQuality[i]));

Loading…
Cancel
Save