Browse Source

Merge branch 'rejoe2-development03' into development03

pull/1367/head
lumapu 1 year ago
parent
commit
c68c3a365f
  1. 6
      src/hm/CommQueue.h
  2. 54
      src/hm/Communication.h

6
src/hm/CommQueue.h

@ -12,9 +12,9 @@
#include "../utils/dbg.h"
// needs a '+1' because the comparison does not send if attempts is equal 0
#define DEFAULT_ATTEMPS 5 + 1
#define MORE_ATTEMPS_ALARMDATA 15 + 1
#define MORE_ATTEMPS_GRIDONPROFILEPARA 15 + 1
#define DEFAULT_ATTEMPS 5
#define MORE_ATTEMPS_ALARMDATA 15
#define MORE_ATTEMPS_GRIDONPROFILEPARA 15
template <uint8_t N=100>
class CommQueue {

54
src/hm/Communication.h

@ -91,6 +91,7 @@ class Communication : public CommQueue<> {
mIsRetransmit = false;
if(NULL == q->iv->radio)
cmdDone(false); // can't communicate while radio is not defined!
mFirstTry = q->iv->isAvailable();
q->iv->mCmd = q->cmd;
q->iv->mIsSingleframeReq = false;
mState = States::START;
@ -140,8 +141,25 @@ class Communication : public CommQueue<> {
if((IV_HMS == q->iv->ivGen) || (IV_HMT == q->iv->ivGen)) {
q->iv->radio->switchFrequency(q->iv, HOY_BOOT_FREQ_KHZ, (q->iv->config->frequency*FREQ_STEP_KHZ + HOY_BASE_FREQ_KHZ));
mWaitTime.startTimeMonitor(1000);
} else if(IV_MI == q->iv->ivGen)
q->iv->mIvTxCnt++;
} else {
if(IV_MI == q->iv->ivGen)
q->iv->mIvTxCnt++;
if(mFirstTry){
mFirstTry = false;
mState = States::START;
setAttempt();
mHeu.evalTxChQuality(q->iv, false, 0, 0);
//q->iv->radioStatistics.rxFailNoAnser++;
q->iv->radioStatistics.retransmits++;
mWaitTime.stopTimeMonitor();
/*if(*mSerialDebug) {
DPRINT_IVID(DBG_INFO, q->iv->id);
DBGPRINTLN(F("second try"));
}*/
return;
}
}
}
closeRequest(q, false);
break;
@ -178,11 +196,11 @@ class Communication : public CommQueue<> {
yield();
}
if(0 == q->attempts) {
/*if(0 == q->attempts) {
DPRINT_IVID(DBG_INFO, q->iv->id);
DBGPRINT(F("no attempts left"));
closeRequest(q, false);
} else {
} else {*/
if(q->iv->ivGen != IV_MI) {
mState = States::CHECK_PACKAGE;
} else {
@ -207,7 +225,7 @@ class Communication : public CommQueue<> {
closeRequest(q, true);
}
}
}
//}
}
break;
@ -235,6 +253,12 @@ class Communication : public CommQueue<> {
}
if(framnr) {
if(0 == q->attempts) {
DPRINT_IVID(DBG_INFO, q->iv->id);
DBGPRINT(F("no attempts left"));
closeRequest(q, false);
return;
}
setAttempt();
if(*mSerialDebug) {
@ -516,15 +540,15 @@ class Communication : public CommQueue<> {
}
void sendRetransmit(const queue_s *q, uint8_t i) {
if(q->attempts) {
//if(q->attempts) {
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (SINGLE_FRAME + i), true);
q->iv->radioStatistics.retransmits++;
mWaitTime.startTimeMonitor(SINGLEFR_TIMEOUT); // timeout
mState = States::WAIT;
} else {
/*} else {
//add(q, true);
closeRequest(q, false);
}
}*/
}
private:
@ -547,7 +571,6 @@ class Communication : public CommQueue<> {
q->iv->mGotLastMsg = false;
q->iv->miMultiParts = 0;
mIsRetransmit = false;
mFirstTry = false; // for correct reset
mState = States::RESET;
DBGPRINTLN(F("-----"));
}
@ -604,6 +627,8 @@ class Communication : public CommQueue<> {
rec->ts = q->ts;
q->iv->setValue(1, rec, (uint32_t) ((p->packet[24] << 8) + p->packet[25])/1);
q->iv->miMultiParts +=4;
rec->mqttSentStatus = MqttSentStatus::NEW_DATA;
} else if ( p->packet[9] == 0x01 || p->packet[9] == 0x10 ) {//second frame for MI, 3rd gen. answers in 0x10
DPRINT_IVID(DBG_INFO, q->iv->id);
if ( p->packet[9] == 0x01 ) {
@ -620,6 +645,7 @@ class Communication : public CommQueue<> {
record_t<> *rec = q->iv->getRecordStruct(InverterDevInform_Simple); // choose the record structure
rec->ts = q->ts;
q->iv->setValue(0, rec, (uint32_t) ((((p->packet[10] << 8) | p->packet[11]) << 8 | p->packet[12]) << 8 | p->packet[13])/1);
rec->mqttSentStatus = MqttSentStatus::NEW_DATA;
if(*mSerialDebug) {
DPRINT(DBG_INFO,F("HW_FB_TLmValue "));
@ -667,6 +693,7 @@ class Communication : public CommQueue<> {
inline void miGPFDecode(packet_t *p, const queue_s *q) {
record_t<> *rec = q->iv->getRecordStruct(InverterDevInform_Simple); // choose the record structure
rec->ts = q->ts;
rec->mqttSentStatus = MqttSentStatus::NEW_DATA;
q->iv->setValue(2, rec, (uint32_t) (((p->packet[10] << 8) | p->packet[11]))); //FLD_GRID_PROFILE_CODE
q->iv->setValue(3, rec, (uint32_t) (((p->packet[12] << 8) | p->packet[13]))); //FLD_GRID_PROFILE_VERSION
@ -849,6 +876,8 @@ class Communication : public CommQueue<> {
if (!stsok) {
q->iv->setValue(q->iv->getPosByChFld(0, FLD_EVT, rec), rec, prntsts);
q->iv->lastAlarm[0] = alarm_t(prntsts, q->ts, 0);
rec->ts = q->ts;
rec->mqttSentStatus = MqttSentStatus::NEW_DATA;
}
if (q->iv->alarmMesIndex < rec->record[q->iv->getPosByChFld(0, FLD_EVT, rec)]) {
@ -907,17 +936,12 @@ class Communication : public CommQueue<> {
iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) ac_pow/10);
iv->doCalculations();
rec->mqttSentStatus = MqttSentStatus::NEW_DATA;
// update status state-machine,
if (ac_pow)
iv->isProducing();
//closeRequest(iv, iv->miMultiParts > 5);
//mHeu.setGotAll(iv);
//cmdDone(false);
if(NULL != mCbPayload)
(mCbPayload)(RealTimeRunData_Debug, iv);
//mState = States::RESET; // everything ok, next request
}
private:

Loading…
Cancel
Save