From 4d19e2dde4cde676347f98733da4dc3a2963511a Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 18 Aug 2023 17:31:57 +0200 Subject: [PATCH] 0.7.37 * fix alarm time on WebGui #1099 * added RSSI info for HMS and HMT inverters (MqTT + REST API) --- src/CHANGES.md | 21 +++++++-------------- src/defines.h | 2 +- src/hm/hmInverter.h | 2 ++ src/hms/hmsPayload.h | 8 ++++++++ src/publisher/pubMqttIvData.h | 6 ++++++ src/web/RestApi.h | 1 + src/web/html/api.js | 4 ++-- src/web/html/visualization.html | 7 +++++-- 8 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index f788eef3..8b2ca4d6 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,15 +1,8 @@ -Changelog v0.7.36 +# Development Changes -* added Ethernet variant -* fix configuration of ePaper -* fix MI inverter support -* endpoints `/api/record/live`, `/api/record/alarm`, `/api/record/config`, `/api/record/info` are obsolete -* added `/api/inverter/alarm/[ID]` to read inverter alarms -* added Alarms in Live View as modal window -* added MqTT transmission of last 10 alarms -* updated documentation -* changed `ESP8266` default NRF24 pin assignments (`D3` = `CE` and `D4` = `IRQ`) -* changed live view to gray once inverter isn't available -> fast identify if inverters are online -* added information about maximum power (AC and DC) -* updated documentation -* several small fixes +## 0.7.37 - 2023-08-18 +* fix alarm time on WebGui #1099 +* added RSSI info for HMS and HMT inverters (MqTT + REST API) + +## 0.7.36 +* last Release diff --git a/src/defines.h b/src/defines.h index 8b6c0dab..163e22b5 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 7 -#define VERSION_PATCH 36 +#define VERSION_PATCH 37 //------------------------------------- typedef struct { diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 594f4211..cfcd134a 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -151,6 +151,7 @@ class Inverter { 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 occured alarms + int8_t rssi; // HMS and HMT inverters only static uint32_t *timestamp; // system timestamp @@ -171,6 +172,7 @@ class Inverter { status = InverterStatus::OFF; alarmNxtWrPos = 0; alarmCnt = 0; + rssi = -127; } ~Inverter() { diff --git a/src/hms/hmsPayload.h b/src/hms/hmsPayload.h index c167fd43..bfa75f1a 100644 --- a/src/hms/hmsPayload.h +++ b/src/hms/hmsPayload.h @@ -19,6 +19,7 @@ typedef struct { //uint8_t invId; uint32_t ts; uint8_t data[MAX_PAYLOAD_ENTRIES][MAX_RF_PAYLOAD_SIZE]; + int8_t rssi[MAX_PAYLOAD_ENTRIES]; uint8_t len[MAX_PAYLOAD_ENTRIES]; bool complete; uint8_t maxPackId; @@ -160,6 +161,7 @@ class HmsPayload { memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->data[11], p->data[0] - 11); mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->data[0] -11; mPayload[iv->id].gotFragment = true; + mPayload[iv->id].rssi[(*pid & 0x7F) - 1] = p->rssi; } if ((*pid & ALL_FRAMES) == ALL_FRAMES) { @@ -281,6 +283,8 @@ class HmsPayload { memset(payload, 0, 150); + int8_t rssi = -127; + for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId); i++) { if((mPayload[iv->id].len[i] + payloadLen) > 150) { DPRINTLN(DBG_ERROR, F("payload buffer to small!")); @@ -288,6 +292,9 @@ class HmsPayload { } memcpy(&payload[payloadLen], mPayload[iv->id].data[i], (mPayload[iv->id].len[i])); payloadLen += (mPayload[iv->id].len[i]); + // get worst RSSI + if(mPayload[iv->id].rssi[i] > rssi) + rssi = mPayload[iv->id].rssi[i]; yield(); } payloadLen -= 2; @@ -310,6 +317,7 @@ class HmsPayload { iv->addValue(i, payload, rec); yield(); } + iv->rssi = rssi; iv->doCalculations(); notify(mPayload[iv->id].txCmd, iv); diff --git a/src/publisher/pubMqttIvData.h b/src/publisher/pubMqttIvData.h index 57bf5609..22a2626d 100644 --- a/src/publisher/pubMqttIvData.h +++ b/src/publisher/pubMqttIvData.h @@ -106,6 +106,12 @@ class PubMqttIvData { snprintf(mVal, 40, "%d", mIv->getLastTs(rec)); mPublish(mSubTopic, mVal, true, QOS_0); + if((mIv->ivGen == IV_HMS) || (mIv->ivGen == IV_HMT)) { + snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/ch0/rssi", mIv->config->name); + snprintf(mVal, 40, "%d", mIv->rssi); + mPublish(mSubTopic, mVal, false, QOS_0); + } + mIv->isProducing(); // recalculate status mState = SEND_DATA; } else if(mSendTotals && mTotalFound) diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 861e8994..ddc16d52 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -367,6 +367,7 @@ class RestApi { obj[F("generation")] = iv->ivGen; obj[F("status")] = (uint8_t)iv->status; obj[F("alarm_cnt")] = iv->alarmCnt; + obj[F("rssi")] = iv->rssi; JsonArray ch = obj.createNestedArray("ch"); diff --git a/src/web/html/api.js b/src/web/html/api.js index 1548190c..93429afc 100644 --- a/src/web/html/api.js +++ b/src/web/html/api.js @@ -126,8 +126,8 @@ function toIsoDateStr(d) { return new Date(d.getTime() + (d.getTimezoneOffset() * -60000)).toISOString().substring(0, 19).replace('T', ', '); } -function toIsoTimeStr(d) { - return new Date(d.getTime() + (d.getTimezoneOffset() * -60000)).toISOString().substring(11, 19).replace('T', ', '); +function toIsoTimeStr(d) { // UTC! + return new Date(d.getTime()).toISOString().substring(11, 19).replace('T', ', '); } function setHide(id, hide) { diff --git a/src/web/html/visualization.html b/src/web/html/visualization.html index cb9b45ef..0194749a 100644 --- a/src/web/html/visualization.html +++ b/src/web/html/visualization.html @@ -166,7 +166,7 @@ ]); } - function tsInfo(ts) { + function tsInfo(ts, gen, rssi) { var ageInfo = "Last received data requested at: "; if(ts > 0) { var date = new Date(ts * 1000); @@ -175,6 +175,9 @@ else ageInfo += "nothing received"; + if((gen >= 2) && (rssi > -127)) + ageInfo += " (RSSI: " + rssi + "dBm)"; + return ml("div", {class: "mb-5"}, [ ml("div", {class: "row p-1 ts-h mx-2"}, ml("div", {class: "col"}, "") @@ -200,7 +203,7 @@ ml("div", {}, [ ivHead(obj), ml("div", {class: "row mb-2"}, chn), - tsInfo(obj.ts_last_success) + tsInfo(obj.ts_last_success, obj.generation, obj.rssi) ]) );