diff --git a/scripts/buildManifest.py b/scripts/buildManifest.py index db29b352..2664a39f 100644 --- a/scripts/buildManifest.py +++ b/scripts/buildManifest.py @@ -33,16 +33,16 @@ def buildManifest(path, infile, outfile): esp32 = {} esp32["chipFamily"] = "ESP32" esp32["parts"] = [] - esp32["parts"].append({"path": "bootloader.bin", "offset": 4096}) - esp32["parts"].append({"path": "partitions.bin", "offset": 32768}) - esp32["parts"].append({"path": "ota.bin", "offset": 57344}) - esp32["parts"].append({"path": version[1] + "_" + sha + "_esp32.bin", "offset": 65536}) + esp32["parts"].append({"path": "ESP32/bootloader.bin", "offset": 4096}) + esp32["parts"].append({"path": "ESP32/partitions.bin", "offset": 32768}) + esp32["parts"].append({"path": "ESP32/ota.bin", "offset": 57344}) + esp32["parts"].append({"path": "ESP32/" + version[1] + "_" + sha + "_esp32.bin", "offset": 65536}) data["builds"].append(esp32) esp8266 = {} esp8266["chipFamily"] = "ESP8266" esp8266["parts"] = [] - esp8266["parts"].append({"path": version[1] + "_" + sha + "_esp8266.bin", "offset": 0}) + esp8266["parts"].append({"path": "ESP8266/" + version[1] + "_" + sha + "_esp8266.bin", "offset": 0}) data["builds"].append(esp8266) jsonString = json.dumps(data, indent=2) diff --git a/scripts/getVersion.py b/scripts/getVersion.py index f0000758..b6bef458 100644 --- a/scripts/getVersion.py +++ b/scripts/getVersion.py @@ -50,63 +50,74 @@ def readVersion(path, infile): versionnumber += line[p+13:].rstrip() + "." os.mkdir(path + "firmware/") - os.mkdir(path + "firmware/s3/") + os.mkdir(path + "firmware/ESP8266/") + os.mkdir(path + "firmware/ESP8285/") + os.mkdir(path + "firmware/ESP32/") + os.mkdir(path + "firmware/ESP32-S2/") + os.mkdir(path + "firmware/ESP32-S3/") sha = os.getenv("SHA",default="sha") versionout = version[:-1] + "_" + sha + "_esp8266.bin" src = path + ".pio/build/esp8266/firmware.bin" - dst = path + "firmware/" + versionout + dst = path + "firmware/ESP8266/" + versionout os.rename(src, dst) versionout = version[:-1] + "_" + sha + "_esp8266_prometheus.bin" src = path + ".pio/build/esp8266-prometheus/firmware.bin" - dst = path + "firmware/" + versionout + dst = path + "firmware/ESP8266/" + versionout os.rename(src, dst) versionout = version[:-1] + "_" + sha + "_esp8285.bin" src = path + ".pio/build/esp8285/firmware.bin" - dst = path + "firmware/" + versionout + dst = path + "firmware/ESP8285/" + versionout os.rename(src, dst) gzip_bin(dst, dst + ".gz") versionout = version[:-1] + "_" + sha + "_esp32.bin" src = path + ".pio/build/esp32-wroom32/firmware.bin" - dst = path + "firmware/" + versionout + dst = path + "firmware/ESP32/" + versionout os.rename(src, dst) versionout = version[:-1] + "_" + sha + "_esp32_prometheus.bin" src = path + ".pio/build/esp32-wroom32-prometheus/firmware.bin" - dst = path + "firmware/" + versionout + dst = path + "firmware/ESP32/" + versionout os.rename(src, dst) versionout = version[:-1] + "_" + sha + "_esp32_ethernet.bin" src = path + ".pio/build/esp32-wroom32-ethernet/firmware.bin" - dst = path + "firmware/" + versionout + dst = path + "firmware/ESP32/" + versionout os.rename(src, dst) versionout = version[:-1] + "_" + sha + "_esp32s2-mini.bin" src = path + ".pio/build/esp32-s2-mini/firmware.bin" - dst = path + "firmware/" + versionout + dst = path + "firmware/ESP32-S2/" + versionout os.rename(src, dst) versionout = version[:-1] + "_" + sha + "_esp32s3.bin" src = path + ".pio/build/opendtufusionv1/firmware.bin" - dst = path + "firmware/s3/" + versionout + dst = path + "firmware/ESP32-S3/" + versionout os.rename(src, dst) # other ESP32 bin files src = path + ".pio/build/esp32-wroom32/" - dst = path + "firmware/" + dst = path + "firmware/ESP32/" os.rename(src + "bootloader.bin", dst + "bootloader.bin") os.rename(src + "partitions.bin", dst + "partitions.bin") - genOtaBin(path + "firmware/") + genOtaBin(dst) - # other ESP32S3 bin files + # other ESP32-S2 bin files + src = path + ".pio/build/esp32-s2-mini/" + dst = path + "firmware/ESP32-S2/" + os.rename(src + "bootloader.bin", dst + "bootloader.bin") + os.rename(src + "partitions.bin", dst + "partitions.bin") + genOtaBin(dst) + + # other ESP32-S3 bin files src = path + ".pio/build/opendtufusionv1/" - dst = path + "firmware/s3/" + dst = path + "firmware/ESP32-S3/" os.rename(src + "bootloader.bin", dst + "bootloader.bin") os.rename(src + "partitions.bin", dst + "partitions.bin") - os.rename(src + "ota.bin", dst + "ota.bin") + genOtaBin(dst) os.rename("../scripts/gh-action-dev-build-flash.html", path + "install.html") diff --git a/src/CHANGES.md b/src/CHANGES.md index d611f052..a16a638e 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,14 @@ # Development Changes +## 0.7.44 - 2023-08-28 +* fix `last_success` transmitted to often #1124 + +## 0.7.43 - 2023-08-28 +* improved RSSI for NRF24, now it's read per package (and inverter) #1129 +* arranged `heap` related info together in `/system` +* fix display navi during save +* clean up binary output, separated to folders + ## 0.7.42 - 2023-08-27 * fix ePaper for opendtufusion_v2.x boards (Software SPI) * add signal strength for NRF24 - PR #1119 diff --git a/src/app.cpp b/src/app.cpp index 13b44fe4..25a849ee 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -145,9 +145,11 @@ void app::loopStandard(void) { if (mConfig->serial.debug) { DPRINT(DBG_INFO, F("RX ")); DBGPRINT(String(p->len)); - DBGPRINT(F("B Ch")); + DBGPRINT(F(" CH")); DBGPRINT(String(p->ch)); - DBGPRINT(F(" | ")); + DBGPRINT(F(", ")); + DBGPRINT(String(p->rssi)); + DBGPRINT(F("dBm | ")); ah::dumpBuf(p->packet, p->len); } mStat.frmCnt++; @@ -172,7 +174,7 @@ void app::loopStandard(void) { if (mConfig->serial.debug) { DPRINT(DBG_INFO, F("RX ")); DBGPRINT(String(p->data[0])); - DBGPRINT(F(" RSSI ")); + DBGPRINT(F(", ")); DBGPRINT(String(p->rssi)); DBGPRINT(F("dBm | ")); ah::dumpBuf(&p->data[1], p->data[0]); diff --git a/src/defines.h b/src/defines.h index 25779f7b..ca67f8fb 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,12 +13,13 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 7 -#define VERSION_PATCH 42 +#define VERSION_PATCH 44 //------------------------------------- typedef struct { uint8_t ch; uint8_t len; + int8_t rssi; uint8_t packet[MAX_RF_PAYLOAD_SIZE]; } packet_t; diff --git a/src/hm/hmDefines.h b/src/hm/hmDefines.h index 3c63aa9e..7b1549ab 100644 --- a/src/hm/hmDefines.h +++ b/src/hm/hmDefines.h @@ -11,7 +11,7 @@ // inverter generations enum {IV_MI = 0, IV_HM, IV_HMS, IV_HMT, IV_UNKNOWN}; -const char* const generationNames[] = {"HM", "MI", "HMS", "HMT", "UNKNOWN"}; +const char* const generationNames[] = {"MI", "HM", "HMS", "HMT", "UNKNOWN"}; // units enum {UNIT_V = 0, UNIT_A, UNIT_W, UNIT_WH, UNIT_KWH, UNIT_HZ, UNIT_C, UNIT_PCT, UNIT_VAR, UNIT_NONE}; diff --git a/src/hm/hmPayload.h b/src/hm/hmPayload.h index 441981cf..f5b56405 100644 --- a/src/hm/hmPayload.h +++ b/src/hm/hmPayload.h @@ -18,6 +18,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; @@ -172,6 +173,7 @@ class HmPayload { memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], p->len - 11); mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->len - 11; mPayload[iv->id].gotFragment = true; + mPayload[iv->id].rssi[(*pid & 0x7F) - 1] = p->rssi; } if ((*pid & ALL_FRAMES) == ALL_FRAMES) { @@ -284,8 +286,8 @@ class HmPayload { } else { // payload complete DPRINT(DBG_INFO, F("procPyld: cmd: 0x")); DBGHEXLN(mPayload[iv->id].txCmd); - DPRINT(DBG_INFO, F("procPyld: txid: 0x")); - DBGHEXLN(mPayload[iv->id].txId); + //DPRINT(DBG_DEBUG, F("procPyld: txid: 0x")); + //DBGHEXLN(mPayload[iv->id].txId); DPRINT(DBG_DEBUG, F("procPyld: max: ")); DPRINTLN(DBG_DEBUG, String(mPayload[iv->id].maxPackId)); record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser @@ -296,6 +298,8 @@ class HmPayload { 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!")); @@ -303,12 +307,16 @@ class HmPayload { } 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; if (mSerialDebug) { - DPRINT(DBG_INFO, F("Payload (")); + DPRINT_IVID(DBG_INFO, iv->id); + DBGPRINT(F("Payload (")); DBGPRINT(String(payloadLen)); DBGPRINT(F("): ")); ah::dumpBuf(payload, payloadLen); @@ -325,6 +333,7 @@ class HmPayload { iv->addValue(i, payload, rec); yield(); } + iv->rssi = rssi; iv->doCalculations(); notify(mPayload[iv->id].txCmd, iv); @@ -388,8 +397,8 @@ class HmPayload { } void reset(uint8_t id) { - DPRINT_IVID(DBG_INFO, id); - DBGPRINTLN(F("resetPayload")); + //DPRINT_IVID(DBG_INFO, id); + //DBGPRINTLN(F("resetPayload")); memset(mPayload[id].len, 0, MAX_PAYLOAD_ENTRIES); mPayload[id].txCmd = 0; mPayload[id].gotFragment = false; diff --git a/src/hm/hmRadio.h b/src/hm/hmRadio.h index cd9018b8..0b5feea5 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/hmRadio.h @@ -239,16 +239,6 @@ class HmRadio { return mNrf24.isPVariant(); } - /* Test whether a signal (carrier or otherwise) greater than or equal to -64dBm is present on the channel. - Valid only on nRF24L01P (+) hardware. On nRF24L01, use testCarrier(). - Useful to check for interference on the current channel and channel hopping strategies. - bool goodSignal = radio.testRPD();*/ - bool goodSignal(void) { - bool goodSignal = mNrf24.testRPD(); - mNrf24.read(0,0); - return goodSignal; - } - std::queue mBufCtrl; uint32_t mSendCnt; @@ -268,16 +258,17 @@ class HmRadio { if (len > 0) { packet_t p; p.ch = mRfChLst[mRxChIdx]; - p.len = len; - mNrf24.read(p.packet, len); + p.len = (len > MAX_RF_PAYLOAD_SIZE) ? MAX_RF_PAYLOAD_SIZE : len; + p.rssi = mNrf24.testRPD() ? -64 : -75; + mNrf24.read(p.packet, p.len); if (p.packet[0] != 0x00) { - mBufCtrl.push(p); - if (p.packet[0] == (TX_REQ_INFO + ALL_FRAMES)) // response from get information command - isLastPackage = (p.packet[9] > ALL_FRAMES); // > ALL_FRAMES indicates last packet received - else if (p.packet[0] == ( 0x0f + ALL_FRAMES) ) // response from MI get information command - isLastPackage = (p.packet[9] > 0x10); // > 0x10 indicates last packet received - else if ((p.packet[0] != 0x88) && (p.packet[0] != 0x92)) // ignore fragment number zero and MI status messages //#0 was p.packet[0] != 0x00 && - isLastPackage = true; // response from dev control command + mBufCtrl.push(p); + if (p.packet[0] == (TX_REQ_INFO + ALL_FRAMES)) // response from get information command + isLastPackage = (p.packet[9] > ALL_FRAMES); // > ALL_FRAMES indicates last packet received + else if (p.packet[0] == ( 0x0f + ALL_FRAMES) ) // response from MI get information command + isLastPackage = (p.packet[9] > 0x10); // > 0x10 indicates last packet received + else if ((p.packet[0] != 0x88) && (p.packet[0] != 0x92)) // ignore fragment number zero and MI status messages //#0 was p.packet[0] != 0x00 && + isLastPackage = true; // response from dev control command } } yield(); @@ -321,7 +312,7 @@ class HmRadio { if(mSerialDebug) { DPRINT(DBG_INFO, F("TX ")); DBGPRINT(String(len)); - DBGPRINT("B Ch"); + DBGPRINT(" CH"); DBGPRINT(String(mRfChLst[mTxChIdx])); DBGPRINT(F(" | ")); ah::dumpBuf(mTxBuf, len); diff --git a/src/hms/hmsPayload.h b/src/hms/hmsPayload.h index bfa75f1a..2ece3c45 100644 --- a/src/hms/hmsPayload.h +++ b/src/hms/hmsPayload.h @@ -272,8 +272,8 @@ class HmsPayload { }*/ else { // payload complete DPRINT(DBG_INFO, F("procPyld: cmd: 0x")); DBGPRINTLN(String(mPayload[iv->id].txCmd, HEX)); - DPRINT(DBG_INFO, F("procPyld: txid: 0x")); - DBGPRINTLN(String(mPayload[iv->id].txId, HEX)); + //DPRINT(DBG_DEBUG, F("procPyld: txid: 0x")); + //DBGPRINTLN(String(mPayload[iv->id].txId, HEX)); DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId)); record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser mPayload[iv->id].complete = true; @@ -300,7 +300,8 @@ class HmsPayload { payloadLen -= 2; if (mSerialDebug) { - DPRINT(DBG_INFO, F("Payload (")); + DPRINT_IVID(DBG_INFO, iv->id); + DBGPRINT(F("Payload (")); DBGPRINT(String(payloadLen)); DBGPRINT(F("): ")); ah::dumpBuf(payload, payloadLen); @@ -382,8 +383,8 @@ class HmsPayload { } void reset(uint8_t id) { - DPRINT(DBG_INFO, "resetPayload: id: "); - DBGPRINTLN(String(id)); + //DPRINT(DBG_INFO, "resetPayload: id: "); + //DBGPRINTLN(String(id)); memset(&mPayload[id], 0, sizeof(hmsPayload_t)); mPayload[id].txCmd = 0; mPayload[id].gotFragment = false; diff --git a/src/publisher/pubMqttIvData.h b/src/publisher/pubMqttIvData.h index 9393733e..8446b4e8 100644 --- a/src/publisher/pubMqttIvData.h +++ b/src/publisher/pubMqttIvData.h @@ -28,7 +28,8 @@ class PubMqttIvData { mState = IDLE; mZeroValues = false; - memset(mIvLastRTRpub, 0, MAX_NUM_INVERTERS * 4); + memset(mIvLastRTRpub, 0, MAX_NUM_INVERTERS * sizeof(uint32_t)); + memset(mIvLastPublish, 0, MAX_NUM_INVERTERS * sizeof(uint32_t)); mRTRDataHasBeenSent = false; mTable[IDLE] = &PubMqttIvData::stateIdle; @@ -102,7 +103,7 @@ class PubMqttIvData { mPos = 0; if(found) { record_t<> *rec = mIv->getRecordStruct(mCmd); - if(mIv->getLastTs(rec) != mIvLastRTRpub[mIv->id]) { + if(mIv->getLastTs(rec) != mIvLastPublish[mIv->id]) { snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/last_success", mIv->config->name); snprintf(mVal, 40, "%d", mIv->getLastTs(rec)); mPublish(mSubTopic, mVal, true, QOS_0); @@ -133,6 +134,7 @@ class PubMqttIvData { pubData &= (lastTs != mIvLastRTRpub[mIv->id]); if (pubData) { + mIvLastPublish[mIv->id] = lastTs; if(mPos < rec->length) { bool retained = false; if (mCmd == RealTimeRunData_Debug) { @@ -239,6 +241,7 @@ class PubMqttIvData { Inverter<> *mIv, *mIvSend; uint8_t mPos; uint32_t mIvLastRTRpub[MAX_NUM_INVERTERS]; + uint32_t mIvLastPublish[MAX_NUM_INVERTERS]; bool mRTRDataHasBeenSent; char mSubTopic[32 + MAX_NAME_LENGTH + 1]; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index cb147a07..095b065e 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -242,10 +242,10 @@ class RestApi { getStatistics(obj.createNestedObject(F("statistics"))); #if defined(ESP32) - obj[F("heap_total")] = ESP.getHeapSize(); obj[F("chip_revision")] = ESP.getChipRevision(); obj[F("chip_model")] = ESP.getChipModel(); obj[F("chip_cores")] = ESP.getChipCores(); + obj[F("heap_total")] = ESP.getHeapSize(); //obj[F("core_version")] = F("n/a"); //obj[F("flash_size")] = F("n/a"); //obj[F("heap_frag")] = F("n/a"); @@ -256,10 +256,10 @@ class RestApi { //obj[F("chip_revision")] = F("n/a"); //obj[F("chip_model")] = F("n/a"); //obj[F("chip_cores")] = F("n/a"); - obj[F("core_version")] = ESP.getCoreVersion(); - obj[F("flash_size")] = ESP.getFlashChipRealSize() / 1024; // in kb obj[F("heap_frag")] = mHeapFrag; obj[F("max_free_blk")] = mHeapFreeBlk; + obj[F("core_version")] = ESP.getCoreVersion(); + obj[F("flash_size")] = ESP.getFlashChipRealSize() / 1024; // in kb obj[F("reboot_reason")] = ESP.getResetReason(); #endif //obj[F("littlefs_total")] = LittleFS.totalBytes(); @@ -502,7 +502,6 @@ class RestApi { obj[F("isconnected")] = mRadio->isChipConnected(); obj[F("DataRate")] = mRadio->getDataRate(); obj[F("isPVariant")] = mRadio->isPVariant(); - obj[F("goodSignal")] = mRadio->goodSignal(); obj[F("en")] = (bool) mConfig->nrf.enabled; } diff --git a/src/web/html/save.html b/src/web/html/save.html index 4c924c40..ce50c6ca 100644 --- a/src/web/html/save.html +++ b/src/web/html/save.html @@ -51,7 +51,9 @@ parseHtml(obj); } } - intervalId = window.setInterval("getAjax('/api/html/save', parse)", 2500); + + intervalId = window.setInterval("getAjax('/api/html/save', parse)", 2500); + getAjax("/api/generic", parseGeneric); diff --git a/src/web/html/setup.html b/src/web/html/setup.html index 3f8a6c64..9df891c8 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -899,8 +899,8 @@ function parse(root) { if(null != root) { - parseSys(root["system"]); parseGeneric(root["generic"]); + parseSys(root["system"]); parseStaticIp(root["static_ip"]); parseMqtt(root["mqtt"]); parseNtp(root["ntp"]); diff --git a/src/web/html/system.html b/src/web/html/system.html index 295f0a55..d51c01cc 100644 --- a/src/web/html/system.html +++ b/src/web/html/system.html @@ -60,9 +60,8 @@ h.appendChild(r); main.appendChild(h); - main.append( - genTabRow("nrf24l01" + (obj["isPVariant"] ? "+ " : ""), (obj["isconnected"] ? "is connected " : "is not connected ")), - genTabRow("NRF Signal: ", (obj["goodSignal"] ? "Strong signal > 64dBm" : "Weak signal < 64dBm")) + main.appendChild( + genTabRow("nrf24l01" + (obj["isPVariant"] ? "+ " : ""), (obj["isconnected"] ? "is connected " : "is not connected ")) ); if(obj["isconnected"]) { diff --git a/src/web/html/visualization.html b/src/web/html/visualization.html index 0d72afac..03ff4083 100644 --- a/src/web/html/visualization.html +++ b/src/web/html/visualization.html @@ -177,8 +177,12 @@ else ageInfo += "nothing received"; - if((gen >= 2) && (rssi > -127)) - ageInfo += " (RSSI: " + rssi + "dBm)"; + if(rssi > -127) { + if(gen < 2) + ageInfo += " (RSSI: " + ((rssi == -64) ? ">=" : "<") + " -64dBm)"; + else + ageInfo += " (RSSI: " + rssi + "dBm)"; + } return ml("div", {class: "mb-5"}, [ ml("div", {class: "row p-1 ts-h mx-2"},