From 4e23784c7356650c22724a399c3928deea124a95 Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Mon, 26 Sep 2022 21:29:40 +0200 Subject: [PATCH] Add nice debug message in setup --- tools/esp8266/html/serial.html | 15 +++++++++++++++ tools/esp8266/web.cpp | 4 ++++ tools/esp8266/webApi.cpp | 6 +++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/esp8266/html/serial.html b/tools/esp8266/html/serial.html index 2f9744fc..933f5bdc 100644 --- a/tools/esp8266/html/serial.html +++ b/tools/esp8266/html/serial.html @@ -20,6 +20,14 @@

handle next buttons with care - test / debug only!!


+ + +
@@ -98,6 +106,7 @@ var obj = new Object(); obj.cmd = 20; obj.tx_request = 81; + obj.inverter = get_selected_iv(); getAjax("/api/ctrl", ctrlCb, "POST", JSON.stringify(obj)); }); @@ -130,6 +139,12 @@ obj.payload = [2000, 1]; getAjax("/api/ctrl", ctrlCb, "POST", JSON.stringify(obj)); }); + + function get_selected_iv() + { + var e = document.getElementById("iv"); + return e.value; + } diff --git a/tools/esp8266/web.cpp b/tools/esp8266/web.cpp index 1aadebc1..858968b8 100644 --- a/tools/esp8266/web.cpp +++ b/tools/esp8266/web.cpp @@ -392,6 +392,10 @@ void web::showWebApi(AsyncWebServerRequest *request) { iv->devControlCmd = TurnOn; iv->devControlRequest = true; // queue it in the request loop } + if (response["cmd"] == (uint8_t)CleanState_LockAndAlarm) { + iv->devControlCmd = CleanState_LockAndAlarm; + iv->devControlRequest = true; // queue it in the request loop + } } } request->send(200, "text/json", "{success:true}"); diff --git a/tools/esp8266/webApi.cpp b/tools/esp8266/webApi.cpp index 21225052..dc08d327 100644 --- a/tools/esp8266/webApi.cpp +++ b/tools/esp8266/webApi.cpp @@ -336,8 +336,12 @@ void webApi::getRecord(JsonObject obj, record_t<> *rec) { //----------------------------------------------------------------------------- bool webApi::setCtrl(DynamicJsonDocument jsonIn, JsonObject jsonOut) { uint8_t cmd = jsonIn[F("cmd")]; + + // Todo: num is the inverter number 0-3. For better display in DPRINTLN + uint8_t num = jsonIn[F("inverter")]; + if(TX_REQ_DEVCONTROL == jsonIn[F("tx_request")]) { - DPRINTLN(DBG_INFO, F("devcontrol, cmd: 0x") + String(cmd, HEX)); + DPRINTLN(DBG_INFO, F("devcontrol [") + String(num) + F("], cmd: 0x") + String(cmd, HEX)); if(ActivePowerContr == cmd) { Inverter<> *iv = getInverter(jsonIn, jsonOut); if(NULL != iv) {