From b4ba35e6ab4f452ebf451789b4cb4c02968b084a Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 5 Jan 2024 14:08:38 +0100 Subject: [PATCH] 0.8.44 * fix MqTT transmission of data #1326 * live data is read much earlier / faster and more often --- src/CHANGES.md | 4 ++++ src/defines.h | 2 +- src/hm/Communication.h | 1 + src/hm/hmInverter.h | 48 ++++++++++++++++++++++++------------------ 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index c416fd806..9dc10a72e 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,9 @@ # Development Changes +## 0.8.44 - 2024-01-05 +* fix MqTT transmission of data #1326 +* live data is read much earlier / faster and more often + ## 0.8.43 - 2024-01-04 * fix display of sunrise in `/system` #1308 * fix overflow of `getLossRate` calculation #1318 diff --git a/src/defines.h b/src/defines.h index 21564fdb6..f0c9731a1 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 43 +#define VERSION_PATCH 44 //------------------------------------- typedef struct { diff --git a/src/hm/Communication.h b/src/hm/Communication.h index 99c8f3820..219cb92eb 100644 --- a/src/hm/Communication.h +++ b/src/hm/Communication.h @@ -498,6 +498,7 @@ class Communication : public CommQueue<> { for (uint8_t i = 0; i < rec->length; i++) { q->iv->addValue(i, mPayload, rec); } + rec->mqttSentStatus = MqttSentStatus::NEW_DATA; q->iv->rssi = rssi; q->iv->doCalculations(); diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 1d38c23f4..a5834d9a1 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -186,28 +186,33 @@ class Inverter { if(mDevControlRequest) { cb(devControlCmd, true); mDevControlRequest = false; - } else if (IV_MI != ivGen) { + } else if (IV_MI != ivGen) { // HM / HMS / HMT mGetLossInterval++; - if((alarmLastId != alarmMesIndex) && (alarmMesIndex != 0)) - cb(AlarmData, false); // get last alarms - else if(0 == getFwVersion()) - cb(InverterDevInform_All, false); // get firmware version - else if(0 == getHwVersion()) - cb(InverterDevInform_Simple, false); // get hardware version - else if(actPowerLimit == 0xffff) - cb(SystemConfigPara, false); // power limit info - else if(InitDataState != devControlCmd) { - cb(devControlCmd, false); // custom command which was received by API - devControlCmd = InitDataState; - mGetLossInterval = 1; - } else if((0 == mGridLen) && generalConfig->readGrid) { // read grid profile - cb(GridOnProFilePara, false); - } else if (mGetLossInterval > AHOY_GET_LOSS_INTERVAL) { // get loss rate - mGetLossInterval = 1; - cb(GetLossRate, false); - } else + if(mNextLive) cb(RealTimeRunData_Debug, false); // get live data - } else { + else { + mNextLive = true; + if(actPowerLimit == 0xffff) + cb(SystemConfigPara, false); // power limit info + else if(InitDataState != devControlCmd) { + cb(devControlCmd, false); // custom command which was received by API + devControlCmd = InitDataState; + mGetLossInterval = 1; + } else if((alarmLastId != alarmMesIndex) && (alarmMesIndex != 0)) + cb(AlarmData, false); // get last alarms + else if(0 == getFwVersion()) + cb(InverterDevInform_All, false); // get firmware version + else if(0 == getHwVersion()) + cb(InverterDevInform_Simple, false); // get hardware version + else if((0 == mGridLen) && generalConfig->readGrid) { // read grid profile + cb(GridOnProFilePara, false); + } else if (mGetLossInterval > AHOY_GET_LOSS_INTERVAL) { // get loss rate + mGetLossInterval = 1; + cb(GetLossRate, false); + } else + cb(RealTimeRunData_Debug, false); // get live data + } + } else { // MI if(0 == getFwVersion()) cb(0x0f, false); // get firmware version; for MI, this makes part of polling the device software and hardware version number else { @@ -319,10 +324,10 @@ class Inverter { rec->record[pos] = (REC_TYP)(val); } } - rec->mqttSentStatus = MqttSentStatus::NEW_DATA; } if(rec == &recordMeas) { + mNextLive = false; // live data received DPRINTLN(DBG_VERBOSE, "add real time"); // get last alarm message index and save it in the inverter object if (getPosByChFld(0, FLD_EVT, rec) == pos) { @@ -832,6 +837,7 @@ class Inverter { uint16_t mIvRxCnt = 0; uint16_t mIvTxCnt = 0; uint8_t mAlarmNxtWrPos = 0; // indicates the position in array (rolling buffer) + bool mNextLive = true; // first read live data after booting up then version etc. public: uint16_t mDtuRxCnt = 0;