diff --git a/src/CHANGES.md b/src/CHANGES.md index 0ba677a3..4a0a2f94 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,10 @@ (starting from release version `0.5.66`) +## 0.5.68 +* repaired receive payload +* Powerlimit is transfered immediately to inverter + ## 0.5.67 * changed calculation of start / stop communication to 1 min after last comm. stop #515 * moved payload send to `payload.h`, function `ivSend` #515 diff --git a/src/app.cpp b/src/app.cpp index b0e310c4..7ad48f26 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -90,6 +90,7 @@ void app::loop(void) { ah::Scheduler::loop(); mSys->Radio.loop(); + mPayload.loop(); yield(); @@ -116,8 +117,6 @@ void app::loop(void) { if (rxRdy) mPayload.process(true); - - mRxTicker = 0; } #if !defined(AP_ONLY) diff --git a/src/app.h b/src/app.h index 54dca314..8663c2a9 100644 --- a/src/app.h +++ b/src/app.h @@ -122,6 +122,10 @@ class app : public IApp, public ah::Scheduler { once(std::bind(&PubMqttType::sendDiscoveryConfig, &mMqtt), 1); } + void ivSendHighPrio(Inverter<> *iv) { + mPayload.ivSendHighPrio(iv); + } + bool getMqttIsConnected() { return mMqtt.isConnected(); } diff --git a/src/appInterface.h b/src/appInterface.h index 94f75399..64acab6b 100644 --- a/src/appInterface.h +++ b/src/appInterface.h @@ -7,6 +7,7 @@ #define __IAPP_H__ #include "defines.h" +#include "hm/hmSystem.h" // abstract interface to App. Make members of App accessible from child class // like web or API without forward declaration @@ -34,6 +35,8 @@ class IApp { virtual bool getSettingsValid() = 0; virtual void setMqttDiscoveryFlag() = 0; + virtual void ivSendHighPrio(Inverter<> *iv) = 0; + virtual bool getMqttIsConnected() = 0; virtual uint32_t getMqttRxCnt() = 0; virtual uint32_t getMqttTxCnt() = 0; diff --git a/src/defines.h b/src/defines.h index 301c9f17..616caa0d 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 67 +#define VERSION_PATCH 68 //------------------------------------- typedef struct { diff --git a/src/hm/payload.h b/src/hm/payload.h index 2a37be32..b0ea7464 100644 --- a/src/hm/payload.h +++ b/src/hm/payload.h @@ -42,6 +42,7 @@ class Payload : public Handler { mTimestamp = timestamp; memset(mPayload, 0, (MAX_NUM_INVERTERS * sizeof(invPayload_t))); mSerialDebug = false; + mHighPrioIv = NULL; } void enableSerialDebug(bool enable) { @@ -54,22 +55,35 @@ class Payload : public Handler { } } - void ivSend(Inverter<> *iv) { - if (!mPayload[iv->id].complete) - process(false); + void loop() { + if(NULL != mHighPrioIv) { + ivSend(mHighPrioIv, true); + mHighPrioIv = NULL; + } + } - if (!mPayload[iv->id].complete) { - if (0 == mPayload[iv->id].maxPackId) - mStat->rxFailNoAnser++; - else - mStat->rxFail++; + void ivSendHighPrio(Inverter<> *iv) { + mHighPrioIv = iv; + } - iv->setQueuedCmdFinished(); // command failed - if (mSerialDebug) - DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout")); - if (mSerialDebug) { - DPRINT(DBG_INFO, F("(#") + String(iv->id) + ") "); - DPRINTLN(DBG_INFO, F("no Payload received! (retransmits: ") + String(mPayload[iv->id].retransmits) + ")"); + void ivSend(Inverter<> *iv, bool highPrio = false) { + if(!highPrio) { + if (!mPayload[iv->id].complete) + process(false); + + if (!mPayload[iv->id].complete) { + if (0 == mPayload[iv->id].maxPackId) + mStat->rxFailNoAnser++; + else + mStat->rxFail++; + + iv->setQueuedCmdFinished(); // command failed + if (mSerialDebug) + DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout")); + if (mSerialDebug) { + DPRINT(DBG_INFO, F("(#") + String(iv->id) + ") "); + DPRINTLN(DBG_INFO, F("no Payload received! (retransmits: ") + String(mPayload[iv->id].retransmits) + ")"); + } } } @@ -180,7 +194,7 @@ class Payload : public Handler { mPayload[iv->id].txCmd = iv->getQueuedCmd(); DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") sendTimePacket")); mSys->Radio.sendTimePacket(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex); - } else if (mPayload[iv->id].maxPackId != 0) { + } else { for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId - 1); i++) { if (mPayload[iv->id].len[i] == 0) { DPRINTLN(DBG_WARN, F("while retrieving data: Frame ") + String(i + 1) + F(" missing: Request Retransmit")); @@ -264,6 +278,7 @@ class Payload : public Handler { uint32_t *mTimestamp; invPayload_t mPayload[MAX_NUM_INVERTERS]; bool mSerialDebug; + Inverter<> *mHighPrioIv; }; #endif /*__PAYLOAD_H_*/ diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 8ad55e26..4246a866 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -534,6 +534,7 @@ class RestApi { iv->powerLimit[1] = AbsolutNonPersistent; iv->devControlCmd = ActivePowerContr; iv->devControlRequest = true; + mApp->ivSendHighPrio(iv); } else if(F("dev") == jsonIn[F("cmd")]) { DPRINTLN(DBG_INFO, F("dev cmd"));