Browse Source

Add nice debug message in setup

pull/313/head
DanielR92 3 years ago
parent
commit
4e23784c73
  1. 15
      tools/esp8266/html/serial.html
  2. 4
      tools/esp8266/web.cpp
  3. 6
      tools/esp8266/webApi.cpp

15
tools/esp8266/html/serial.html

@ -20,6 +20,14 @@
<hr>
<h3>handle next buttons with care - test / debug only!!</h3>
<br/>
<label for="iv">Choose ur Inverter:</label>
<select name="iv" id="iv">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<br/>
<input type="button" value="power limit 100%" class="btn" id="pwrlim2"/>
<input type="button" value="power limit 10%" class="btn" id="pwrlim"/>
<input type="button" value="Turn Off" class="btn" id="turnoff"/>
@ -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;
}
</script>
</body>
</html>

4
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}");

6
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) {

Loading…
Cancel
Save