Browse Source

* created new API functions

* bound html through ajax to parse setup page (not finished now)
* added compression option for static html to python module
* removed generated h-file from index (redundant information), they will be created on compile time
pull/283/head
lumapu 2 years ago
parent
commit
13c88b3626
  1. 1
      .gitignore
  2. 100
      tools/esp8266/api.cpp
  3. 32
      tools/esp8266/api.h
  4. 2
      tools/esp8266/defines.h
  5. 30
      tools/esp8266/html/convert.py
  6. 100
      tools/esp8266/html/h/favicon_ico_gz.h
  7. 5
      tools/esp8266/html/h/index_html.h
  8. 5
      tools/esp8266/html/h/setup_html.h
  9. 5
      tools/esp8266/html/h/style_css.h
  10. 5
      tools/esp8266/html/h/visualization_html.h
  11. 165
      tools/esp8266/html/setup.html
  12. 88
      tools/esp8266/web.cpp
  13. 6
      tools/esp8266/web.h

1
.gitignore

@ -21,3 +21,4 @@ tools/esp8266/.vscode/extensions.json
.DS_Store
.vscode
tools/esp8266/platformio-device-monitor-*.log
tools/esp8266/html/h/*

100
tools/esp8266/api.cpp

@ -0,0 +1,100 @@
//-----------------------------------------------------------------------------
// 2022 Ahoy, https://www.mikrocontroller.net/topic/525778
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
//-----------------------------------------------------------------------------
#if defined(ESP32) && defined(F)
#undef F
#define F(sl) (sl)
#endif
#include "api.h"
#include "AsyncJson.h"
//-----------------------------------------------------------------------------
api::api(AsyncWebServer *srv, app *app, sysConfig_t *sysCfg, config_t *config, char version[]) {
mSrv = srv;
mApp = app;
mSysCfg = sysCfg;
mConfig = config;
mVersion = version;
}
//-----------------------------------------------------------------------------
void api::setup(void) {
mSrv->on("/api/system", HTTP_GET, std::bind(&api::onSystem, this, std::placeholders::_1));
mSrv->on("/api/inverter/list", HTTP_GET, std::bind(&api::onInverterList, this, std::placeholders::_1));
mSrv->on("/api/mqtt", HTTP_GET, std::bind(&api::onMqtt, this, std::placeholders::_1));
}
//-----------------------------------------------------------------------------
void api::loop(void) {
}
//-----------------------------------------------------------------------------
void api::onSystem(AsyncWebServerRequest *request) {
AsyncJsonResponse* response = new AsyncJsonResponse();
JsonObject root = response->getRoot();
root[F("ssid")] = mSysCfg->stationSsid;
root[F("device_name")] = mSysCfg->deviceName;
response->setLength();
//response->addHeader("Access-Control-Allow-Origin", "*");
//response->addHeader("Access-Control-Allow-Headers", "content-type");
request->send(response);
}
//-----------------------------------------------------------------------------
void api::onInverterList(AsyncWebServerRequest *request) {
AsyncJsonResponse* response = new AsyncJsonResponse();
JsonObject root = response->getRoot();
JsonArray invArr = root.createNestedArray("inverter");
Inverter<> *iv;
for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) {
iv = mApp->mSys->getInverterByPos(i);
if(NULL != iv) {
JsonObject obj = invArr.createNestedObject();
obj[F("id")] = i;
obj[F("name")] = String(iv->name);
obj[F("serial")] = String(iv->serial.u64, HEX);
obj[F("channels")] = iv->channels;
obj[F("version")] = String(iv->fwVersion);
for(uint8_t j = 0; j < iv->channels; j ++) {
obj[F("ch_max_power")][j] = iv->chMaxPwr[j];
obj[F("ch_name")][j] = iv->chName[j];
}
obj[F("power_limit")][F("limit")] = iv->powerLimit[0];
obj[F("power_limit")][F("limit_option")] = iv->powerLimit[1];
}
}
root[F("interval")] = String(mConfig->sendInterval);
root[F("retries")] = String(mConfig->maxRetransPerPyld);
response->setLength();
request->send(response);
}
//-----------------------------------------------------------------------------
void api::onMqtt(AsyncWebServerRequest *request) {
AsyncJsonResponse* response = new AsyncJsonResponse();
JsonObject root = response->getRoot();
root[F("broker")] = String(mConfig->mqtt.broker);
root[F("port")] = String(mConfig->mqtt.port);
root[F("user")] = String(mConfig->mqtt.user);
root[F("pwd")] = String(mConfig->mqtt.pwd); // TODO: not that nice!
root[F("topic")] = String(mConfig->mqtt.topic);
response->setLength();
request->send(response);
}

32
tools/esp8266/api.h

@ -0,0 +1,32 @@
#ifndef __API_H__
#define __API_H__
#include "dbg.h"
#include "ESPAsyncTCP.h"
#include "ESPAsyncWebServer.h"
#include "app.h"
class app;
class api {
public:
api(AsyncWebServer *srv, app *app, sysConfig_t *sysCfg, config_t *config, char version[]);
void setup(void);
void loop(void);
private:
void onSystem(AsyncWebServerRequest *request);
void onInverterList(AsyncWebServerRequest *request);
void onMqtt(AsyncWebServerRequest *request);
AsyncWebServer *mSrv;
app *mApp;
config_t *mConfig;
sysConfig_t *mSysCfg;
char *mVersion;
};
#endif /*__API_H__*/

2
tools/esp8266/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 5
#define VERSION_PATCH 16
#define VERSION_PATCH 17
//-------------------------------------

30
tools/esp8266/html/convert.py

@ -1,7 +1,8 @@
import re
import os
import gzip
def convert2Header(inFile):
def convert2Header(inFile, compress):
fileType = inFile.split(".")[1]
define = inFile.split(".")[0].upper()
define2 = inFile.split(".")[1].upper()
@ -17,6 +18,7 @@ def convert2Header(inFile):
f = open(inFile, "r")
data = f.read().replace('\n', '')
f.close()
if False == compress:
if fileType == "html":
data = re.sub(r"\>\s+\<", '><', data) # whitespaces between xml tags
data = re.sub(r"(\;|\}|\>|\{)\s+", r'\1', data) # whitespaces inner javascript
@ -25,17 +27,33 @@ def convert2Header(inFile):
else:
data = re.sub(r"(\;|\}|\:|\{)\s+", r'\1', data) # whitespaces inner css
length = len(data) # get unescaped length
else:
data = re.sub(r"\>\s+\<", '><', data) # whitespaces between xml tags
data = re.sub(r"(\;|\}|\>|\{)\s+", r'\1', data) # whitespaces inner javascript
length = len(data) # get unescaped length
f = open(outName, "w")
f.write("#ifndef __{}_{}_H__\n".format(define, define2))
f.write("#define __{}_{}_H__\n".format(define, define2))
if compress:
zipped = gzip.compress(bytes(data, 'utf-8'))
zippedStr = ""
for i in range(len(zipped)):
zippedStr += "0x{:02x}".format(zipped[i]) #hex(zipped[i])
if (i + 1) != len(zipped):
zippedStr += ", "
if (i + 1) % 16 == 0 and i != 0:
zippedStr += "\n"
f.write("#define {}_len {}\n".format(inFileVarName, len(zipped)))
f.write("const uint8_t {}[] PROGMEM = {{\n{}}};\n".format(inFileVarName, zippedStr))
else:
f.write("const char {}[] PROGMEM = \"{}\";\n".format(inFileVarName, data))
f.write("const uint32_t {}_len = {};\n".format(inFileVarName, length))
f.write("#endif /*__{}_{}_H__*/\n".format(define, define2))
f.close()
convert2Header("index.html")
convert2Header("setup.html")
convert2Header("visualization.html")
convert2Header("update.html")
convert2Header("style.css")
convert2Header("index.html", False)
convert2Header("setup.html", True)
convert2Header("visualization.html", False)
convert2Header("update.html", False)
convert2Header("style.css", False)

100
tools/esp8266/html/h/favicon_ico_gz.h

@ -1,100 +0,0 @@
#ifndef __FAVICON_ICO_GZ_H__
#define __FAVICON_ICO_GZ_H__
#define favicon_ico_gz_len 1533
const uint8_t favicon_ico_gz[] PROGMEM = {0x1f, 0x8b, 0x08, 0x08, 0xf2, 0xc5, 0xd5, 0x62, 0x04, 0x00, 0x66, 0x61, 0x76, 0x69, 0x63, 0x6f,
0x6e, 0x2e, 0x69, 0x63, 0x6f, 0x00, 0xed, 0x5c, 0x49, 0x68, 0x13, 0x51, 0x18, 0xfe, 0x62, 0xa3,
0x51, 0x28, 0xd6, 0x83, 0x82, 0xa0, 0x98, 0xb8, 0x1c, 0xbc, 0x59, 0x11, 0x5c, 0x50, 0xac, 0x88,
0x8a, 0xb8, 0xdd, 0x3c, 0x89, 0xd0, 0x93, 0x7a, 0x53, 0x51, 0x9b, 0x80, 0x4b, 0x46, 0xad, 0xfb,
0xd2, 0xb4, 0x2e, 0xb8, 0xa3, 0xc6, 0xba, 0xe1, 0x02, 0xae, 0xad, 0x0a, 0x26, 0x3d, 0xe8, 0xc5,
0x83, 0x57, 0x31, 0x2d, 0xc1, 0x8b, 0xb7, 0x92, 0x63, 0x0e, 0xa1, 0xcf, 0xff, 0xcf, 0xbc, 0xc9,
0x32, 0xa4, 0x66, 0xcf, 0x4b, 0xf3, 0xfa, 0xc3, 0xc7, 0x97, 0xcc, 0xcc, 0xcb, 0xf7, 0xbe, 0x6f,
0x26, 0x6f, 0x26, 0xf3, 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0x4d, 0xf2, 0x4a,
0xc3, 0xe4, 0x15, 0x21, 0xb9, 0x7d, 0x54, 0x72, 0xbb, 0xe4, 0x56, 0xc9, 0x33, 0x25, 0x37, 0x4b,
0x76, 0x49, 0x6e, 0x92, 0xec, 0xb0, 0xf4, 0xec, 0x1c, 0x93, 0x1c, 0x97, 0x9c, 0x90, 0x3c, 0x22,
0x59, 0x58, 0x7c, 0x46, 0xf2, 0x77, 0xc9, 0x7f, 0x25, 0x8b, 0x82, 0xd8, 0x41, 0x7f, 0x3b, 0x91,
0xec, 0x8f, 0x10, 0x21, 0x66, 0xfe, 0x67, 0x06, 0xe6, 0x16, 0x21, 0x62, 0xcc, 0x6e, 0x21, 0xe2,
0xcc, 0x6d, 0x42, 0x24, 0x98, 0xfd, 0x42, 0x8c, 0x30, 0x0b, 0x2a, 0xf6, 0xcf, 0x7c, 0x87, 0x72,
0x61, 0x4e, 0xe4, 0x67, 0x3f, 0xf3, 0x08, 0x7d, 0x28, 0x4f, 0x16, 0x1c, 0x26, 0x1b, 0x4d, 0xb4,
0x90, 0x56, 0x85, 0x5c, 0xb4, 0x11, 0x6d, 0x1a, 0x6d, 0x21, 0x55, 0x52, 0x8e, 0x31, 0xf8, 0x31,
0x2f, 0xe3, 0x75, 0xff, 0x00, 0xd3, 0x39, 0x74, 0x2c, 0x6e, 0x57, 0x00, 0x00};
#endif /*__FAVICON_ICO_GZ_H__*/

5
tools/esp8266/html/h/index_html.h

@ -1,5 +0,0 @@
#ifndef __INDEX_HTML_H__
#define __INDEX_HTML_H__
const char index_html[] PROGMEM = "<!doctype html><html><head><title>Index - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script type=\"text/javascript\">getAjax('/uptime', 'uptime');getAjax('/cmdstat', 'cmds');window.setInterval(\"getAjax('/uptime', 'uptime')\", {JS_TS});window.setInterval(\"getAjax('/cmdstat', 'cmds')\", {JS_TS});function getAjax(url, resid) {var http = null;http = new XMLHttpRequest();if(http != null) {http.open(\"GET\", url, true);http.onreadystatechange = print;http.send(null);}function print() {if(http.readyState == 4) {document.getElementById(resid).innerHTML = http.responseText;}}}function getInverterInfo(data){var http = null;http = new XMLHttpRequest();if(http != null) {http.open(\"POST\", \"/api\");http.setRequestHeader(\"Accept\", \"application/json\");http.setRequestHeader(\"Content-Type\", \"application/json\");http.send(data);}}</script></head><body><h1>AHOY - {DEVICE}</h1><div id=\"content\" class=\"content\"><p><a href=\"/visualization\">Visualization</a><br/><br/><a href=\"/setup\">Setup</a><br/></p><p><span class=\"des\">Uptime: </span><span id=\"uptime\"></span></p><p><span class=\"des\">Statistics: </span><pre id=\"cmds\"></pre></p><p>Every {TS}seconds the values are updated</p><div id=\"note\">This project was started from <a href=\"https://www.mikrocontroller.net/topic/525778\" target=\"_blank\">this discussion. (Mikrocontroller.net)</a><br/>New updates can be found on Github: <a href=\"https://github.com/grindylow/ahoy\" target=\"_blank\">https://github.com/grindylow/ahoy</a><br/><br/>Please report issues using the feature provided by <a href=\"https://github.com/grindylow/ahoy/issues\">Github</a><br/><br/>Discuss with us on <a href=\"https://discord.gg/WzhxEY62mB\">Discord</a><br/><p class=\"lic\"><a href=\"https://creativecommons.org/licenses/by-nc-sa/3.0/de\">Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/</a><br/>Check the licenses which are published on <a href=\"https://github.com/grindylow/ahoy\">https://github.com/grindylow/ahoy</a>as well</p></div></div><div id=\"footer\"><p class=\"left\">&copy 2022</p><p class=\"left\"><a href=\"/update\">Update Firmware</a></p><p class=\"right\">AHOY :: {VERSION}</p><p class=\"right\"><a href=\"/reboot\">Reboot</a></p><p class=\"right\">Git SHA: {BUILD}</p></div></body></html>";
const uint32_t index_html_len = 2317;
#endif /*__INDEX_HTML_H__*/

5
tools/esp8266/html/h/setup_html.h

File diff suppressed because one or more lines are too long

5
tools/esp8266/html/h/style_css.h

@ -1,5 +0,0 @@
#ifndef __STYLE_CSS_H__
#define __STYLE_CSS_H__
const char style_css[] PROGMEM = "h1 {margin:0;padding:20pt;font-size:22pt;color:#fff;background-color:#006ec0;display:block;text-transform:uppercase;}html, body {font-family:Arial;margin:0;padding:0;}p {text-align:justify;font-size:13pt;}p.lic, p.lic a {font-size:8pt;color:#999;}.des {margin-top:20px;font-size:13pt;color:#006ec0;}.s_active, .s_collapsible:hover {background-color:#006ec0;}.s_content {display:none;overflow:hidden;}.s_collapsible {background-color:#044e86;color:white;cursor:pointer;padding:18px;width:100%;border:none;text-align:left;outline:none;font-size:15px;margin-bottom:4px;}.subdes {font-size:12pt;color:#006ec0;margin-left:7px;}.subsubdes {font-size:12pt;color:#006ec0;margin:0 0 7px 12px;}.hide {display:none;}a:link, a:visited {text-decoration:none;font-size:13pt;color:#006ec0;}a:hover, a:focus {color:#f00;}a.erase {background-color:#006ec0;color:#fff;padding:7px;display:inline-block;margin-top:30px;}#content {padding:15px 15px 60px 15px;}#footer {position:fixed;bottom:0px;height:45px;background-color:#006ec0;width:100%;border-top:5px solid #fff;}#footer p, #footer a {color:#fff;padding:0 7px 0 7px;font-size:10pt !important;}div.content {background-color:#fff;padding-bottom:65px;overflow:auto;}input, select {padding:7px;font-size:13pt;}input.text, select {width:70%;box-sizing:border-box;margin-bottom:10px;border:1px solid #ccc;}input.sh {max-width:150px !important;margin-right:10px;}input.btn {background-color:#006ec0;color:#fff;border:0px;float:right;margin:10px 0 30px;text-transform:uppercase;}input.cb {margin-bottom:20px;}label {width:20%;display:inline-block;font-size:12pt;padding-right:10px;margin:10px 0px 0px 15px;vertical-align:top;}fieldset {margin-bottom:15px;}.left {float:left;}.right {float:right;}div.ch-iv {width:100%;background-color:#32b004;display:inline-block;margin-bottom:15px;padding-bottom:20px;overflow:auto;}div.ch {width:220px;min-height:350px;background-color:#006ec0;display:inline-block;margin:0 10px 15px 10px;overflow:auto;padding-bottom:20px;}div.ch .value, div.ch .info, div.ch .head, div.ch-iv .value, div.ch-iv .info, div.ch-iv .head {color:#fff;display:block;width:100%;text-align:center;}.subgrp {float:left;width:220px;}div.ch .unit, div.ch-iv .unit {font-size:19px;margin-left:10px;}div.ch .value, div.ch-iv .value {margin-top:20px;font-size:24px;}div.ch .info, div.ch-iv .info {margin-top:3px;font-size:10px;}div.ch .head {background-color:#003c80;padding:10px 0 10px 0;}div.ch-iv .head {background-color:#1c6800;padding:10px 0 10px 0;}div.iv {max-width:960px;margin-bottom:40px;}div.ts {font-size:13px;background-color:#ddd;border-top:7px solid #999;padding:7px;}div.modpwr, div.modname {width:70%;display:inline-block;}#note {margin:50px 10px 10px 10px;padding-top:10px;width:100%;border-top:1px solid #bbb;}@media(max-width:500px) {div.ch .unit, div.ch-iv .unit {font-size:18px;}div.ch {width:170px;min-height:100px }.subgrp {width:180px;}}";
const uint32_t style_css_len = 2899;
#endif /*__STYLE_CSS_H__*/

5
tools/esp8266/html/h/visualization_html.h

@ -1,5 +0,0 @@
#ifndef __VISUALIZATION_HTML_H__
#define __VISUALIZATION_HTML_H__
const char visualization_html[] PROGMEM = "<!doctype html><html><head><title>Index - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script type=\"text/javascript\">getAjax('/livedata', 'livedata');window.setInterval(\"getAjax('/livedata', 'livedata')\", {JS_TS});function getAjax(url, resid) {var http = null;http = new XMLHttpRequest();if(http != null) {http.open(\"GET\", url, true);http.onreadystatechange = print;http.send(null);}function print() {if(http.readyState == 4) {document.getElementById(resid).innerHTML = http.responseText;}}}</script><style type=\"text/css\"></style></head><body><h1>AHOY - {DEVICE}</h1><div id=\"content\" class=\"content\"><div id=\"livedata\"></div><p>Every {TS}seconds the values are updated</p></div><div id=\"footer\"><p class=\"left\">&copy 2022</p><p class=\"left\"><a href=\"/\">Home</a></p><p class=\"right\">AHOY :: {VERSION}</p></div></body></html>";
const uint32_t visualization_html_len = 922;
#endif /*__VISUALIZATION_HTML_H__*/

165
tools/esp8266/html/setup.html

@ -54,11 +54,11 @@
<div id="content">
<a class="erase" href="/erase">ERASE SETTINGS (not WiFi)</a>
<form method="post" action="{#IP}/save">
<form method="post" action="/save">
<fieldset>
<legend class="des">Device Host Name</legend>
<label for="device">Device Name</label>
<input type="text" class="text" name="device" value="{#DEVICE}"/>
<input type="text" name="device" class="text"/>
</fieldset>
<button type="button" class="s_collapsible">WiFi</button>
@ -67,7 +67,7 @@
<legend class="des">WiFi</legend>
<p>Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.</p>
<label for="ssid">SSID</label>
<input type="text" class="text" name="ssid" value="{#SSID}"/>
<input type="text" name="ssid" class="text"/>
<label for="pwd">Password</label>
<input type="password" class="text" name="pwd" value="{#PWD}"/>
</fieldset>
@ -77,12 +77,12 @@
<div class="s_content">
<fieldset>
<legend class="des">Inverter</legend>
{#INVERTERS}<br/>
<div id="inverter"></div><br/>
<p class="subdes">General</p>
<label for="invInterval">Interval [s]</label>
<input type="text" class="text" name="invInterval" value="{#INV_INTVL}"/>
<input type="text" class="text" name="invInterval"/>
<label for="invRetry">Max retries per Payload</label>
<input type="text" class="text" name="invRetry" value="{#INV_RETRIES}"/>
<input type="text" class="text" name="invRetry"/>
</fieldset>
</div>
@ -102,15 +102,15 @@
<fieldset>
<legend class="des">MQTT</legend>
<label for="mqttAddr">Broker / Server IP</label>
<input type="text" class="text" name="mqttAddr" value="{#MQTT_ADDR}"/>
<input type="text" class="text" name="mqttAddr"/>
<label for="mqttPort">Port</label>
<input type="text" class="text" name="mqttPort" value="{#MQTT_PORT}"/>
<input type="text" class="text" name="mqttPort"/>
<label for="mqttUser">Username (optional)</label>
<input type="text" class="text" name="mqttUser" value="{#MQTT_USER}"/>
<input type="text" class="text" name="mqttUser"/>
<label for="mqttPwd">Password (optional)</label>
<input type="text" class="text" name="mqttPwd" value="{#MQTT_PWD}"/>
<input type="text" class="text" name="mqttPwd"/>
<label for="mqttTopic">Topic</label>
<input type="text" class="text" name="mqttTopic" value="{#MQTT_TOPIC}"/>
<input type="text" class="text" name="mqttTopic"/>
</fieldset>
</div>
@ -143,11 +143,11 @@
</div>
<div id="footer">
<p class="left"><a href="{#IP}/">Home</a></p>
<p class="left"><a href="{#IP}/update">Update Firmware</a></p>
<p class="left"><a href="/">Home</a></p>
<p class="left"><a href="/update">Update Firmware</a></p>
<p class="right">AHOY - {#VERSION}</p>
<p class="right"><a href="{#IP}/factory">Factory Reset</a></p>
<p class="right"><a href="{#IP}/reboot">Reboot</a></p>
<p class="right"><a href="/factory">Factory Reset</a></p>
<p class="right"><a href="/reboot">Reboot</a></p>
</div>
<script type="text/javascript">
@ -160,6 +160,141 @@
content.style.display = (content.style.display === "block") ? "none" : "block";
});
}
function getAjax(url, ptr) {
var http = null;
http = new XMLHttpRequest();
if(http != null) {
http.open("GET", url, true);
http.onreadystatechange = p;
http.send(null);
}
function p() {
if(http.readyState == 4)
ptr(http.responseText);
}
}
function des(val) {
e = document.createElement('p');
e.classList.add("subdes");
e.innerHTML = val;
return e;
}
function lbl(id, val) {
e = document.createElement('label');
e.htmlFor = id;
e.innerHTML = val;
return e;
}
function inp(name, val, max=32, cl=["text"]) {
e = document.createElement('input');
e.classList.add(...cl);
e.name = name;
e.value = val;
e.maxLength = max;
return e;
}
function sel(name, opt, selId) {
e = document.createElement('select');
e.name = name;
for(i = 0; i < opt.length; i++) {
o = document.createElement('option');
o.value = opt[i][0];
o.innerHTML = opt[i][1];
if(opt[i][0] == selId)
o.selected = true;
e.appendChild(o);
}
return e;
}
function div(cl) {
e = document.createElement('div');
e.classList.add(cl);
return e;
}
function ivHtml(obj, id) {
iv = document.getElementById("inverter");
id = "inv" + id;
iv.appendChild(des("Inverter " + id));
iv.appendChild(lbl(id + "Addr", "Adress*"));
iv.appendChild(inp(id + "Addr", obj.serial, 12));
iv.appendChild(lbl(id + "Name", "Name*"));
iv.appendChild(inp(id + "Name", obj.name));
iv.appendChild(lbl(id + "ActivePowerLimit", "Active Power Limit"));
iv.appendChild(inp(id + "ActivePowerLimit", obj.power_limit.limit, 5));
iv.appendChild(lbl(id + "ActivePowerLimitConType", "Active Power Limit Control Type"));
iv.appendChild(sel(id + "ActivePowerLimitConType", [
[65535, "no power limit"],
[0, "absolute in Watt non persistent"],
[1, "absolute in Watt persistent"],
[256, "relativ in percent non persistent"],
[257, "relativ in percent persistent"]
], obj.power_limit.limit_option));
iv.appendChild(lbl(id + "ModPwr", "Max Module Power (Wp)"));
d = div("modpwr");
for(i = 0; i < obj.channels; i++) {
d.appendChild(inp(id + "ModPwr" + i, obj.ch_max_power[i], 4, ["text", "sh"]))
}
iv.appendChild(d);
iv.appendChild(lbl(id + "ModName", "Module Name"));
d = div("modname");
for(i = 0; i < obj.channels; i++) {
d.appendChild(inp(id + "ModName" + i, obj.ch_name[i], 4, ["text", "sh"]))
}
iv.appendChild(d);
}
function ivGlob(obj) {
e = document.getElementsByName("invInterval");
e[0].value = obj["interval"];
e = document.getElementsByName("invRetry");
e[0].value = obj["retries"];
}
function parseSys(json) {
obj = JSON.parse(json);
e = document.getElementsByName("device");
e[0].value = obj.device_name;
e = document.getElementsByName("ssid");
e[0].value = obj.ssid;
}
function parseIv(json) {
obj = JSON.parse(json);
ivHtml(obj.inverter[0], 0);
ivGlob(obj);
}
function parseMqtt(json) {
obj = JSON.parse(json);
e = document.getElementsByName("mqttAddr");
e[0].value = obj["broker"];
e = document.getElementsByName("mqttPort");
e[0].value = obj["port"];
e = document.getElementsByName("mqttUser");
e[0].value = obj["user"];
e = document.getElementsByName("mqttPwd");
e[0].value = obj["pwd"];
e = document.getElementsByName("mqttTopic");
e[0].value = obj["topic"];
}
getAjax("/api/system", parseSys);
getAjax("/api/inverter/list", parseIv);
getAjax("/api/mqtt", parseMqtt);
</script>
</body>
</html>

88
tools/esp8266/web.cpp

@ -41,6 +41,9 @@ web::web(app *main, sysConfig_t *sysCfg, config_t *config, char version[]) {
mConfig = config;
mVersion = version;
mWeb = new AsyncWebServer(80);
//mEvts = new AsyncEventSource("/events");
mApi = new api(mWeb, main, sysCfg, config, version);
}
@ -71,15 +74,31 @@ void web::setup(void) {
mWeb->on("/update", HTTP_GET, std::bind(&web::showUpdateForm, this, std::placeholders::_1));
mWeb->on("/update", HTTP_POST, std::bind(&web::showUpdate, this, std::placeholders::_1),
std::bind(&web::showUpdate2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6));
//mEvts->onConnect(std::bind(&web::onConnect, this, std::placeholders::_1));
//mWeb->addHandler(mEvts);
mApi->setup();
}
//-----------------------------------------------------------------------------
void web::loop(void) {
mApi->loop();
}
//-----------------------------------------------------------------------------
/*void web::onConnect(AsyncEventSourceClient *client) {
DPRINTLN(DBG_INFO, "onConnect");
if(client->lastId())
DPRINTLN(DBG_INFO, "Client reconnected! Last message ID that it got is: " + String(client->lastId()));
client->send("hello!", NULL, millis(), 1000);
}*/
//-----------------------------------------------------------------------------
void web::showIndex(AsyncWebServerRequest *request) {
DPRINTLN(DBG_VERBOSE, F("showIndex"));
@ -192,8 +211,11 @@ void web::showFactoryRst(AsyncWebServerRequest *request) {
void web::showSetup(AsyncWebServerRequest *request) {
DPRINTLN(DBG_VERBOSE, F("app::showSetup"));
tmplProc *proc = new tmplProc(request, 11000);
proc->process(setup_html, setup_html_len, std::bind(&web::showSetupCb, this, std::placeholders::_1));
//tmplProc *proc = new tmplProc(request, 11000);
//proc->process(setup_html, setup_html_len, std::bind(&web::showSetupCb, this, std::placeholders::_1));
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html"), setup_html, setup_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
@ -391,7 +413,6 @@ void web::showLiveData(AsyncWebServerRequest *request) {
}
}
modHtml += "</div>";
yield();
}
modHtml += F("<div class=\"ts\">Last received data requested at: ") + mMain->getDateTimeStr(iv->ts) + F("</div>");
modHtml += F("</div>");
@ -563,64 +584,6 @@ String web::showSetupCb(char* key) {
if(generic.length() == 0) {
if(0 == strncmp(key, "SSID", 4)) return mSysCfg->stationSsid;
else if(0 == strncmp(key, "PWD", 3)) return F("{PWD}");
else if(0 == strncmp(key, "INVERTERS", 9)) {
String inv = "";
Inverter<> *iv;
for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) {
iv = mMain->mSys->getInverterByPos(i);
inv += F("<p class=\"subdes\">Inverter ") + String(i) + "</p>";
inv += F("<label for=\"inv") + String(i) + F("Addr\">Address*</label>");
inv += F("<input type=\"text\" class=\"text\" name=\"inv") + String(i) + F("Addr\" value=\"");
if(NULL != iv)
inv += String(iv->serial.u64, HEX);
inv += F("\"/ maxlength=\"12\">");
inv += F("<label for=\"inv") + String(i) + F("Name\">Name*</label>");
inv += F("<input type=\"text\" class=\"text\" name=\"inv") + String(i) + F("Name\" value=\"");
if(NULL != iv)
inv += String(iv->name);
inv += F("\"/ maxlength=\"") + String(MAX_NAME_LENGTH) + "\">";
inv += F("<label for=\"inv") + String(i) + F("ActivePowerLimit\">Active Power Limit</label>");
inv += F("<input type=\"text\" class=\"text\" name=\"inv") + String(i) + F("ActivePowerLimit\" value=\"");
if(NULL != iv)
inv += String(iv->powerLimit[0]);
inv += F("\"/ maxlength=\"") + String(6) + "\">";
inv += F("<label for=\"inv") + String(i) + F("ActivePowerLimitConType\">Active Power Limit Control Type</label>");
inv += F("<select name=\"inv") + String(i) + F("PowerLimitControl\">");
for(uint8_t j = 0; j < 5; j++) {
inv += F("<option value=\"") + String(pwrLimitOptionValues[j]) + F("\"");
if(NULL != iv) {
if(iv->powerLimit[1] == pwrLimitOptionValues[j])
inv += F(" selected");
}
inv += F(">") + String(pwrLimitOptions[j]) + F("</option>");
}
inv += F("</select>");
inv += F("<label for=\"inv") + String(i) + F("ModPwr0\" name=\"lbl") + String(i);
inv += F("ModPwr\">Max Module Power (Wp)</label><div class=\"modpwr\">");
for(uint8_t j = 0; j < 4; j++) {
inv += F("<input type=\"text\" class=\"text sh\" name=\"inv") + String(i) + F("ModPwr") + String(j) + F("\" value=\"");
if(NULL != iv)
inv += String(iv->chMaxPwr[j]);
inv += F("\"/ maxlength=\"4\">");
}
inv += F("</div><br/><label for=\"inv") + String(i) + F("ModName0\" name=\"lbl") + String(i);
inv += F("ModName\">Module Name</label><div class=\"modname\">");
for(uint8_t j = 0; j < 4; j++) {
inv += F("<input type=\"text\" class=\"text sh\" name=\"inv") + String(i) + F("ModName") + String(j) + F("\" value=\"");
if(NULL != iv)
inv += String(iv->chName[j]);
inv += F("\"/ maxlength=\"") + String(MAX_NAME_LENGTH) + "\">";
}
inv += F("</div>");
}
DPRINTLN(DBG_INFO, inv);
return inv;
}
else if(0 == strncmp(key, "PINOUT", 6)) {
String pinout = "";
for(uint8_t i = 0; i < 3; i++) {
@ -661,7 +624,6 @@ String web::showSetupCb(char* key) {
else if(0 == strncmp(key, "MQTT_USER", 9)) return String(mConfig->mqtt.user);
else if(0 == strncmp(key, "MQTT_PWD", 8)) return String(mConfig->mqtt.pwd);
else if(0 == strncmp(key, "MQTT_TOPIC", 10)) return String(mConfig->mqtt.topic);
//else if(0 == strncmp(key, "MQTT_INTVL", 10)) return String(mMqttInterval);
}
return generic;

6
tools/esp8266/web.h

@ -10,9 +10,11 @@
#include "ESPAsyncTCP.h"
#include "ESPAsyncWebServer.h"
#include "app.h"
#include "api.h"
#include "tmplProc.h"
class app;
class api;
class web {
public:
@ -22,6 +24,8 @@ class web {
void setup(void);
void loop(void);
void onConnect(AsyncEventSourceClient *client);
void showIndex(AsyncWebServerRequest *request);
void showCss(AsyncWebServerRequest *request);
void showFavicon(AsyncWebServerRequest *request);
@ -49,11 +53,13 @@ class web {
String showUpdateFormCb(char* key);
AsyncWebServer *mWeb;
AsyncEventSource *mEvts;
config_t *mConfig;
sysConfig_t *mSysCfg;
char *mVersion;
app *mMain;
api *mApi;
};
#endif /*__WEB_H__*/

Loading…
Cancel
Save