From 86ff9f054a166a19f2558f9760019ec97de88dee Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 30 Dec 2023 02:33:57 +0100 Subject: [PATCH] 0.8.35 * changed reload time for opendtufusion after update to 5s * fix default interval and gap for communication * fix serial number in exported json (was decimal, now correct as hexdecimal number) * beautified factory reset * added second stage for erase settings * increased maximal number of inverters to 32 for opendtufusion board (ESP32-S3) * fixed crash if CMT inverter is enabled, but CMT isn't configured --- .github/workflows/compile_release.yml | 2 +- src/CHANGES.md | 6 ++++ src/app.cpp | 3 ++ src/config/config.h | 6 +++- src/config/settings.h | 6 ++-- src/web/RestApi.h | 48 +++++++++++++++++++++++++++ src/web/html/system.html | 3 +- src/web/web.h | 47 ++++++++------------------ 8 files changed, 79 insertions(+), 42 deletions(-) diff --git a/.github/workflows/compile_release.yml b/.github/workflows/compile_release.yml index e65494ab8..a7e3511d6 100644 --- a/.github/workflows/compile_release.yml +++ b/.github/workflows/compile_release.yml @@ -77,7 +77,7 @@ jobs: VERSION: ${{ steps.rename-binary-files.outputs.name }} - name: Create Artifact - run: zip --junk-paths ${{ steps.rename-binary-files.outputs.name }}.zip src/firmware/* User_Manual.md + run: zip --junk-paths ${{ steps.rename-binary-files.outputs.name }}.zip src/firmware/* User_Manual.md - name: Upload Release id: upload-release diff --git a/src/CHANGES.md b/src/CHANGES.md index 52f185f38..7c2433564 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -3,6 +3,12 @@ ## 0.8.35 - 2023-12-30 * added dim option for LEDS * changed reload time for opendtufusion after update to 5s +* fix default interval and gap for communication +* fix serial number in exported json (was decimal, now correct as hexdecimal number) +* beautified factory reset +* added second stage for erase settings +* increased maximal number of inverters to 32 for opendtufusion board (ESP32-S3) +* fixed crash if CMT inverter is enabled, but CMT isn't configured # RELEASE 0.8.34 - 2023-12-29 diff --git a/src/app.cpp b/src/app.cpp index 5a5a54a06..0bba14da3 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -354,6 +354,9 @@ void app::tickSend(void) { continue; } + if(!iv->radio->isChipConnected()) + continue; + iv->tickSend([this, iv](uint8_t cmd, bool isDevControl) { if(isDevControl) mCommunication.addImportant(iv, cmd); diff --git a/src/config/config.h b/src/config/config.h index c8fd86dcd..2cb9bcd3f 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -153,7 +153,11 @@ // number of configurable inverters #if defined(ESP32) - #define MAX_NUM_INVERTERS 16 + #if defined(CONFIG_IDF_TARGET_ESP32S3) + #define MAX_NUM_INVERTERS 32 + #else + #define MAX_NUM_INVERTERS 16 + #endif #else #define MAX_NUM_INVERTERS 4 #endif diff --git a/src/config/settings.h b/src/config/settings.h index c797cad8b..fe2ad1b0b 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -425,7 +425,7 @@ class settings { mCfg.serial.showIv = false; mCfg.serial.debug = false; mCfg.serial.privacyLog = true; - mCfg.serial.printWholeTrace = true; + mCfg.serial.printWholeTrace = false; mCfg.mqtt.port = DEF_MQTT_PORT; snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", DEF_MQTT_BROKER); @@ -441,7 +441,7 @@ class settings { mCfg.inst.startWithoutTime = false; mCfg.inst.rstMaxValsMidNight = false; mCfg.inst.yieldEffiency = 1.0f; - mCfg.inst.gapMs = 2000; + mCfg.inst.gapMs = 500; mCfg.inst.readGrid = true; for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { @@ -456,8 +456,6 @@ class settings { mCfg.led.high_active = LED_HIGH_ACTIVE; mCfg.led.luminance = 255; - memset(&mCfg.inst, 0, sizeof(cfgInst_t)); - mCfg.plugin.display.pwrSaveAtIvOffline = false; mCfg.plugin.display.contrast = 60; mCfg.plugin.display.screenSaver = 1; // default: 1 .. pixelshift for OLED for downward compatibility diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 169e1d2d4..a74f4f140 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -88,6 +88,10 @@ class RestApi { else if(path == "html/logout") getHtmlLogout(request, root); else if(path == "html/reboot") getHtmlReboot(request, root); else if(path == "html/save") getHtmlSave(request, root); + else if(path == "html/erase") getHtmlErase(request, root); + else if(path == "html/erasetrue") getHtmlEraseTrue(request, root); + else if(path == "html/factory") getHtmlFactory(request, root); + else if(path == "html/factorytrue") getHtmlFactoryTrue(request, root); else if(path == "system") getSysInfo(request, root); else if(path == "generic") getGeneric(request, root); else if(path == "reboot") getReboot(request, root); @@ -214,6 +218,16 @@ class RestApi { tmp.remove(i, tmp.indexOf("\"", i)-i); } } + i = 0; + // convert all serial numbers to hexadecimal + while (i != -1) { + i = tmp.indexOf("\"sn\":", i); + if(-1 != i) { + i+=5; + String sn = tmp.substring(i, tmp.indexOf("\"", i)-1); + tmp.replace(sn, String(atoll(sn.c_str()), HEX)); + } + } response = request->beginResponse(200, F("application/json; charset=utf-8"), tmp); } @@ -337,6 +351,40 @@ class RestApi { #endif } + void getHtmlErase(AsyncWebServerRequest *request, JsonObject obj) { + getGeneric(request, obj.createNestedObject(F("generic"))); + obj[F("html")] = F("Erase settings (not WiFi)? yes no"); + } + + void getHtmlEraseTrue(AsyncWebServerRequest *request, JsonObject obj) { + getGeneric(request, obj.createNestedObject(F("generic"))); + mApp->eraseSettings(false); + mApp->setRebootFlag(); + obj[F("html")] = F("Erase settings: success"); + #if defined(ETHERNET) && defined(CONFIG_IDF_TARGET_ESP32S3) + obj[F("reload")] = 5; + #else + obj[F("reload")] = 20; + #endif + } + + void getHtmlFactory(AsyncWebServerRequest *request, JsonObject obj) { + getGeneric(request, obj.createNestedObject(F("generic"))); + obj[F("html")] = F("Factory reset? yes no"); + } + + void getHtmlFactoryTrue(AsyncWebServerRequest *request, JsonObject obj) { + getGeneric(request, obj.createNestedObject(F("generic"))); + mApp->eraseSettings(true); + mApp->setRebootFlag(); + obj[F("html")] = F("Factory reset: success"); + #if defined(ETHERNET) && defined(CONFIG_IDF_TARGET_ESP32S3) + obj[F("reload")] = 5; + #else + obj[F("reload")] = 20; + #endif + } + void getReboot(AsyncWebServerRequest *request, JsonObject obj) { getGeneric(request, obj.createNestedObject(F("generic"))); obj[F("refresh")] = 10; diff --git a/src/web/html/system.html b/src/web/html/system.html index ef487ad54..eb25d5fa7 100644 --- a/src/web/html/system.html +++ b/src/web/html/system.html @@ -126,8 +126,7 @@ meta.httpEquiv = "refresh" meta.content = obj.refresh + "; URL=" + obj.refresh_url; document.getElementsByTagName('head')[0].appendChild(meta); - } - else { + } else if(null != obj.system) { parseRadio(obj.system); parseMqtt(obj.system.mqtt); parseSysInfo(obj.system); diff --git a/src/web/web.h b/src/web/web.h index b60e67919..1e87547bf 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -71,14 +71,15 @@ class Web { mWeb.onNotFound ( std::bind(&Web::showNotFound, this, std::placeholders::_1)); mWeb.on("/reboot", HTTP_ANY, std::bind(&Web::onReboot, this, std::placeholders::_1)); mWeb.on("/system", HTTP_ANY, std::bind(&Web::onSystem, this, std::placeholders::_1)); - mWeb.on("/erase", HTTP_ANY, std::bind(&Web::showErase, this, std::placeholders::_1)); - mWeb.on("/factory", HTTP_ANY, std::bind(&Web::showFactoryRst, this, std::placeholders::_1)); + mWeb.on("/erase", HTTP_ANY, std::bind(&Web::showHtml, this, std::placeholders::_1)); + mWeb.on("/erasetrue", HTTP_ANY, std::bind(&Web::showHtml, this, std::placeholders::_1)); + mWeb.on("/factory", HTTP_ANY, std::bind(&Web::showHtml, this, std::placeholders::_1)); + mWeb.on("/factorytrue", HTTP_ANY, std::bind(&Web::showHtml, this, std::placeholders::_1)); mWeb.on("/setup", HTTP_GET, std::bind(&Web::onSetup, this, std::placeholders::_1)); mWeb.on("/save", HTTP_POST, std::bind(&Web::showSave, this, std::placeholders::_1)); mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1)); - //mWeb.on("/api1", HTTP_POST, std::bind(&Web::showWebApi, this, std::placeholders::_1)); #ifdef ENABLE_PROMETHEUS_EP mWeb.on("/metrics", HTTP_ANY, std::bind(&Web::showMetrics, this, std::placeholders::_1)); @@ -197,6 +198,11 @@ class Web { #if !defined(ETHERNET) strncpy(mConfig->sys.stationPwd, pwd, PWD_LEN); // restore WiFi PWD #endif + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + if((mConfig->inst.iv[i].serial.u64 != 0) && (mConfig->inst.iv[i].serial.u64 < 138999999999)) { // hexadecimal + mConfig->inst.iv[i].serial.u64 = ah::Serial2u64(String(mConfig->inst.iv[i].serial.u64).c_str()); + } + } mApp->saveSettings(true); } if (!mUploadFail) @@ -426,39 +432,12 @@ class Web { request->send(response); } - void showErase(AsyncWebServerRequest *request) { + void showHtml(AsyncWebServerRequest *request) { checkProtection(request); - DPRINTLN(DBG_VERBOSE, F("showErase")); - mApp->eraseSettings(false); - onReboot(request); - } - - void showFactoryRst(AsyncWebServerRequest *request) { - checkProtection(request); - - DPRINTLN(DBG_VERBOSE, F("showFactoryRst")); - String content = ""; - int refresh = 3; - if (request->args() > 0) { - if (request->arg("reset").toInt() == 1) { - refresh = 10; - if (mApp->eraseSettings(true)) - content = F("factory reset: success\n\nrebooting ... "); - else - content = F("factory reset: failed\n\nrebooting ... "); - } else { - content = F("factory reset: aborted"); - refresh = 3; - } - } else { - content = F("

Factory Reset

" - "

RESET

CANCEL

"); - refresh = 120; - } - request->send(200, F("text/html; charset=UTF-8"), F("Factory Reset") + content + F("")); - if (refresh == 10) - onReboot(request); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); } void onSetup(AsyncWebServerRequest *request) {