From cefcc9c8c3bb980b67cb2061f3bb56f3bc4aaab8 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 17 Sep 2023 22:11:12 +0200 Subject: [PATCH] 0.7.56 * only request alarms which were not received before #1113 * added flag if alarm was requested but not received and re-request it #1105 --- src/CHANGES.md | 4 ++++ src/defines.h | 2 +- src/hm/hmInverter.h | 10 +++++++++- src/hm/hmPayload.h | 8 ++++---- src/hm/hmRadio.h | 4 ++-- src/hms/hmsPayload.h | 6 +++--- src/hms/hmsRadio.h | 4 ++-- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 28c28d37..d599c410 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,9 @@ # Development Changes +## 0.7.56 - 2023-09-17 +* only request alarms which were not received before #1113 +* added flag if alarm was requested but not received and re-request it #1105 + ## 0.7.55 - 2023-09-17 * fix prometheus builds * fix ESP32 default pinout #1159 diff --git a/src/defines.h b/src/defines.h index 91f649c5..4921e05c 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 7 -#define VERSION_PATCH 55 +#define VERSION_PATCH 56 //------------------------------------- typedef struct { diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index a43788a9..4c850781 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -145,13 +145,14 @@ class Inverter { record_t recordHwInfo; // structure for simple (hardware) info values record_t recordConfig; // structure for system config values record_t recordAlarm; // structure for alarm values - //String lastAlarmMsg; bool initialized; // needed to check if the inverter was correctly added (ESP32 specific - union types are never null) bool isConnected; // shows if inverter was successfully identified (fw version and hardware info) InverterStatus status; // indicates the current inverter status std::array lastAlarm; // holds last 10 alarms uint8_t alarmNxtWrPos; // indicates the position in array (rolling buffer) uint16_t alarmCnt; // counts the total number of occurred alarms + uint8_t alarmLastId; // lastId which was received + bool alarmReqPending; // alarmData request issued and wait for answer int8_t rssi; // HMS and HMT inverters only @@ -173,6 +174,7 @@ class Inverter { status = InverterStatus::OFF; alarmNxtWrPos = 0; alarmCnt = 0; + alarmLastId = 0; rssi = -127; } @@ -208,6 +210,8 @@ class Inverter { enqueCommand(InverterDevInform_All); // firmware version else if (getHwVersion() == 0) enqueCommand(InverterDevInform_Simple); // hardware version + else if(alarmReqPending) + enqueCommand(AlarmData); // alarm not answered enqueCommand(RealTimeRunData_Debug); // live data } else if (ivGen == IV_MI){ if (getFwVersion() == 0) { @@ -338,6 +342,7 @@ class Inverter { DPRINT(DBG_INFO, "alarm ID incremented to "); DBGPRINTLN(String(alarmMesIndex)); + alarmReqPending = true; enqueCommand(AlarmData); } } @@ -598,6 +603,7 @@ class Inverter { lastAlarm.fill({0, 0, 0}); alarmNxtWrPos = 0; alarmCnt = 0; + alarmLastId = 0; } uint16_t parseAlarmLog(uint8_t id, uint8_t pyld[], uint8_t len) { @@ -620,7 +626,9 @@ class Inverter { DPRINTLN(DBG_DEBUG, "Alarm #" + String(pyld[startOff+1]) + " '" + String(getAlarmStr(pyld[startOff+1])) + "' start: " + ah::getTimeStr(start) + ", end: " + ah::getTimeStr(endTime)); addAlarm(pyld[startOff+1], start, endTime); + alarmReqPending = false; alarmCnt++; + alarmLastId = alarmMesIndex; return pyld[startOff+1]; } diff --git a/src/hm/hmPayload.h b/src/hm/hmPayload.h index deefe876..15a16bba 100644 --- a/src/hm/hmPayload.h +++ b/src/hm/hmPayload.h @@ -154,7 +154,7 @@ class HmPayload { DPRINT_IVID(DBG_INFO, iv->id); DBGPRINT(F("prepareDevInformCmd 0x")); DBGHEXLN(cmd); - mRadio->prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false); + mRadio->prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmLastId, false); mPayload[iv->id].txCmd = cmd; } } @@ -253,7 +253,7 @@ class HmPayload { DPRINTLN(DBG_WARN, F("nothing received: Request Complete Retransmit")); mPayload[iv->id].txCmd = iv->getQueuedCmd(); DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd 0x") + String(mPayload[iv->id].txCmd, HEX)); - mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true); + mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmLastId, true); */ DPRINT_IVID(DBG_INFO, iv->id); DBGPRINTLN(F("nothing received")); @@ -286,7 +286,7 @@ class HmPayload { DBGPRINT(F("prepareDevInformCmd 0x")); DBGHEXLN(mPayload[iv->id].txCmd); } - mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true); + mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmLastId, true); } } else { // payload complete if (mSerialDebug) { @@ -364,7 +364,7 @@ class HmPayload { DBGHEXLN(cmd); } mStat->rxSuccess++; - mRadio->prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false); + mRadio->prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmLastId, false); mPayload[iv->id].txCmd = cmd; } diff --git a/src/hm/hmRadio.h b/src/hm/hmRadio.h index b8365bf3..aaa0d3e3 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/hmRadio.h @@ -216,10 +216,10 @@ class HmRadio { mTxBuf[10] = cmd; // cid mTxBuf[11] = 0x00; CP_U32_LittleEndian(&mTxBuf[12], ts); - /*if (cmd == AlarmData ) { //cmd == RealTimeRunData_Debug || + if (cmd == AlarmData ) { //cmd == RealTimeRunData_Debug || mTxBuf[18] = (alarmMesId >> 8) & 0xff; mTxBuf[19] = (alarmMesId ) & 0xff; - }*/ + } sendPacket(invId, 24, isRetransmit); } diff --git a/src/hms/hmsPayload.h b/src/hms/hmsPayload.h index 2ece3c45..e082f059 100644 --- a/src/hms/hmsPayload.h +++ b/src/hms/hmsPayload.h @@ -143,7 +143,7 @@ class HmsPayload { DPRINT_IVID(DBG_INFO, iv->id); DBGPRINT(F("prepareDevInformCmd 0x")); DBGHEXLN(cmd); - mRadio->prepareDevInformCmd(&iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false); + mRadio->prepareDevInformCmd(&iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmLastId, false); mPayload[iv->id].txCmd = cmd; } } @@ -238,7 +238,7 @@ class HmsPayload { //DPRINTLN(DBG_WARN, F("nothing received: Request Complete Retransmit")); //mPayload[iv->id].txCmd = iv->getQueuedCmd(); //DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd 0x") + String(mPayload[iv->id].txCmd, HEX)); - //mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true); + //mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmLastId, true); DPRINT_IVID(DBG_INFO, iv->id); DBGPRINTLN(F("nothing received")); @@ -267,7 +267,7 @@ class HmsPayload { DBGPRINT(String(iv->id)); DBGPRINT(F(") prepareDevInformCmd 0x")); DBGPRINTLN(String(mPayload[iv->id].txCmd, HEX)); - mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true); + mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmLastId, true); } }*/ else { // payload complete DPRINT(DBG_INFO, F("procPyld: cmd: 0x")); diff --git a/src/hms/hmsRadio.h b/src/hms/hmsRadio.h index d8ac0131..e579deda 100644 --- a/src/hms/hmsRadio.h +++ b/src/hms/hmsRadio.h @@ -104,10 +104,10 @@ class CmtRadio { initPacket(ivId, reqfld, ALL_FRAMES); mTxBuf[10] = cmd; CP_U32_LittleEndian(&mTxBuf[12], ts); - /*if (cmd == AlarmData ) { //cmd == RealTimeRunData_Debug || + if (cmd == AlarmData ) { //cmd == RealTimeRunData_Debug || mTxBuf[18] = (alarmMesId >> 8) & 0xff; mTxBuf[19] = (alarmMesId ) & 0xff; - }*/ + } sendPacket(24, isRetransmit); }