From 99f829ac8738fcc83b8ea76cbc7241b7e914d9df Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 19 May 2022 08:12:09 +0200 Subject: [PATCH] * added free heap, mentioned in #24 (added in serial print, status on index and mqtt) * fixed #45, AC current by factor 10 too high * fixed failed payload counter --- tools/esp8266/app.cpp | 18 +++++++++++++----- tools/esp8266/defines.h | 2 +- tools/esp8266/hmDefines.h | 10 +++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 8f18b1df..cb2dd828 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -194,6 +194,8 @@ void app::loop(void) { } } } + snprintf(val, 10, "%d", ESP.getFreeHeap()); + mMqtt.sendMsg("free_heap", val); } } @@ -220,6 +222,9 @@ void app::loop(void) { if(++mSendTicker >= mSendInterval) { mSendTicker = 0; + if(mSerialDebug) + DPRINTLN("Free heap: 0x" + String(ESP.getFreeHeap(), HEX)); + if(!mSys->BufCtrl.empty()) { if(mSerialDebug) DPRINTLN("recbuf not empty! #" + String(mSys->BufCtrl.getFill())); @@ -231,16 +236,17 @@ void app::loop(void) { // reset payload data memset(mPayload[iv->id].len, 0, MAX_PAYLOAD_ENTRIES); mPayload[iv->id].maxPackId = 0; - if(mSerialDebug) { - if(!mPayload[iv->id].complete) - processPayload(false); + if(!mPayload[iv->id].complete) + processPayload(false); - if(!mPayload[iv->id].complete) { + if(!mPayload[iv->id].complete) { + mRxFailed++; + if(mSerialDebug) { DPRINT("Inverter #" + String(iv->id) + " "); DPRINTLN("no Payload received!"); - mRxFailed++; } } + mPayload[iv->id].complete = false; mPayload[iv->id].ts = mTimestamp; @@ -482,6 +488,8 @@ void app::showStatistics(void) { String content = "Failed Payload: " + String(mRxFailed) + "\n"; content += "Send Cnt: " + String(mSys->Radio.mSendCnt) + String("\n\n"); + content += "Free Heap: 0x" + String(ESP.getFreeHeap(), HEX) + "\n"; + if(!mSys->Radio.isChipConnected()) content += "WARNING! your NRF24 module can't be reached, check the wiring and pinout (setup)\n"; diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 42ffc784..99ef1df3 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -16,7 +16,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 4 -#define VERSION_PATCH 3 +#define VERSION_PATCH 4 //------------------------------------- diff --git a/tools/esp8266/hmDefines.h b/tools/esp8266/hmDefines.h index 4cba1791..56f3fd09 100644 --- a/tools/esp8266/hmDefines.h +++ b/tools/esp8266/hmDefines.h @@ -85,12 +85,12 @@ const byteAssign_t hm2chAssignment[] = { { FLD_YT, UNIT_KWH, CH2, 18, 4, 1000 }, { FLD_UAC, UNIT_V, CH0, 26, 2, 10 }, - { FLD_IAC, UNIT_A, CH0, 34, 2, 10 }, + { FLD_IAC, UNIT_A, CH0, 34, 2, 100 }, { FLD_PAC, UNIT_W, CH0, 30, 2, 10 }, { FLD_F, UNIT_HZ, CH0, 28, 2, 100 }, { FLD_T, UNIT_C, CH0, 38, 2, 10 }, - { FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC }, - { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC } + { FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC }, + { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC } }; #define HM2CH_LIST_LEN (sizeof(hm2chAssignment) / sizeof(byteAssign_t)) @@ -130,8 +130,8 @@ const byteAssign_t hm4chAssignment[] = { { FLD_F, UNIT_HZ, CH0, 48, 2, 100 }, { FLD_PCT, UNIT_PCT, CH0, 56, 2, 10 }, { FLD_T, UNIT_C, CH0, 58, 2, 10 }, - { FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC }, - { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC } + { FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC }, + { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC } }; #define HM4CH_LIST_LEN (sizeof(hm4chAssignment) / sizeof(byteAssign_t))