mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-08 13:41:40 +02:00
MI-MQTT and last retransmit
- fix MI not sending data over MQTT (discord1196092306
) - change logic for last retransmit (discord1196098984
)
This commit is contained in:
parent
f4a82242df
commit
e44e722315
2 changed files with 22 additions and 15 deletions
|
@ -12,9 +12,9 @@
|
||||||
#include "../utils/dbg.h"
|
#include "../utils/dbg.h"
|
||||||
|
|
||||||
// needs a '+1' because the comparison does not send if attempts is equal 0
|
// needs a '+1' because the comparison does not send if attempts is equal 0
|
||||||
#define DEFAULT_ATTEMPS 5 + 1
|
#define DEFAULT_ATTEMPS 5
|
||||||
#define MORE_ATTEMPS_ALARMDATA 15 + 1
|
#define MORE_ATTEMPS_ALARMDATA 15
|
||||||
#define MORE_ATTEMPS_GRIDONPROFILEPARA 15 + 1
|
#define MORE_ATTEMPS_GRIDONPROFILEPARA 15
|
||||||
|
|
||||||
template <uint8_t N=100>
|
template <uint8_t N=100>
|
||||||
class CommQueue {
|
class CommQueue {
|
||||||
|
|
|
@ -178,11 +178,11 @@ class Communication : public CommQueue<> {
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 == q->attempts) {
|
/*if(0 == q->attempts) {
|
||||||
DPRINT_IVID(DBG_INFO, q->iv->id);
|
DPRINT_IVID(DBG_INFO, q->iv->id);
|
||||||
DBGPRINT(F("no attempts left"));
|
DBGPRINT(F("no attempts left"));
|
||||||
closeRequest(q, false);
|
closeRequest(q, false);
|
||||||
} else {
|
} else {*/
|
||||||
if(q->iv->ivGen != IV_MI) {
|
if(q->iv->ivGen != IV_MI) {
|
||||||
mState = States::CHECK_PACKAGE;
|
mState = States::CHECK_PACKAGE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -207,7 +207,7 @@ class Communication : public CommQueue<> {
|
||||||
closeRequest(q, true);
|
closeRequest(q, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -235,6 +235,12 @@ class Communication : public CommQueue<> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(framnr) {
|
if(framnr) {
|
||||||
|
if(0 == q->attempts) {
|
||||||
|
DPRINT_IVID(DBG_INFO, q->iv->id);
|
||||||
|
DBGPRINT(F("no attempts left"));
|
||||||
|
closeRequest(q, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setAttempt();
|
setAttempt();
|
||||||
|
|
||||||
if(*mSerialDebug) {
|
if(*mSerialDebug) {
|
||||||
|
@ -516,15 +522,15 @@ class Communication : public CommQueue<> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendRetransmit(const queue_s *q, uint8_t i) {
|
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->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (SINGLE_FRAME + i), true);
|
||||||
q->iv->radioStatistics.retransmits++;
|
q->iv->radioStatistics.retransmits++;
|
||||||
mWaitTime.startTimeMonitor(SINGLEFR_TIMEOUT); // timeout
|
mWaitTime.startTimeMonitor(SINGLEFR_TIMEOUT); // timeout
|
||||||
mState = States::WAIT;
|
mState = States::WAIT;
|
||||||
} else {
|
/*} else {
|
||||||
//add(q, true);
|
//add(q, true);
|
||||||
closeRequest(q, false);
|
closeRequest(q, false);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -604,6 +610,8 @@ class Communication : public CommQueue<> {
|
||||||
rec->ts = q->ts;
|
rec->ts = q->ts;
|
||||||
q->iv->setValue(1, rec, (uint32_t) ((p->packet[24] << 8) + p->packet[25])/1);
|
q->iv->setValue(1, rec, (uint32_t) ((p->packet[24] << 8) + p->packet[25])/1);
|
||||||
q->iv->miMultiParts +=4;
|
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
|
} 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);
|
DPRINT_IVID(DBG_INFO, q->iv->id);
|
||||||
if ( p->packet[9] == 0x01 ) {
|
if ( p->packet[9] == 0x01 ) {
|
||||||
|
@ -620,6 +628,7 @@ class Communication : public CommQueue<> {
|
||||||
record_t<> *rec = q->iv->getRecordStruct(InverterDevInform_Simple); // choose the record structure
|
record_t<> *rec = q->iv->getRecordStruct(InverterDevInform_Simple); // choose the record structure
|
||||||
rec->ts = q->ts;
|
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);
|
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) {
|
if(*mSerialDebug) {
|
||||||
DPRINT(DBG_INFO,F("HW_FB_TLmValue "));
|
DPRINT(DBG_INFO,F("HW_FB_TLmValue "));
|
||||||
|
@ -667,6 +676,7 @@ class Communication : public CommQueue<> {
|
||||||
inline void miGPFDecode(packet_t *p, const queue_s *q) {
|
inline void miGPFDecode(packet_t *p, const queue_s *q) {
|
||||||
record_t<> *rec = q->iv->getRecordStruct(InverterDevInform_Simple); // choose the record structure
|
record_t<> *rec = q->iv->getRecordStruct(InverterDevInform_Simple); // choose the record structure
|
||||||
rec->ts = q->ts;
|
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(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
|
q->iv->setValue(3, rec, (uint32_t) (((p->packet[12] << 8) | p->packet[13]))); //FLD_GRID_PROFILE_VERSION
|
||||||
|
@ -849,6 +859,8 @@ class Communication : public CommQueue<> {
|
||||||
if (!stsok) {
|
if (!stsok) {
|
||||||
q->iv->setValue(q->iv->getPosByChFld(0, FLD_EVT, rec), rec, prntsts);
|
q->iv->setValue(q->iv->getPosByChFld(0, FLD_EVT, rec), rec, prntsts);
|
||||||
q->iv->lastAlarm[0] = alarm_t(prntsts, q->ts, 0);
|
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)]) {
|
if (q->iv->alarmMesIndex < rec->record[q->iv->getPosByChFld(0, FLD_EVT, rec)]) {
|
||||||
|
@ -907,17 +919,12 @@ class Communication : public CommQueue<> {
|
||||||
iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) ac_pow/10);
|
iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) ac_pow/10);
|
||||||
|
|
||||||
iv->doCalculations();
|
iv->doCalculations();
|
||||||
|
rec->mqttSentStatus = MqttSentStatus::NEW_DATA;
|
||||||
// update status state-machine,
|
// update status state-machine,
|
||||||
if (ac_pow)
|
if (ac_pow)
|
||||||
iv->isProducing();
|
iv->isProducing();
|
||||||
//closeRequest(iv, iv->miMultiParts > 5);
|
|
||||||
|
|
||||||
//mHeu.setGotAll(iv);
|
|
||||||
//cmdDone(false);
|
|
||||||
if(NULL != mCbPayload)
|
if(NULL != mCbPayload)
|
||||||
(mCbPayload)(RealTimeRunData_Debug, iv);
|
(mCbPayload)(RealTimeRunData_Debug, iv);
|
||||||
|
|
||||||
//mState = States::RESET; // everything ok, next request
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue