Added configuration of GPIO in UI. Added initial setup page in AP mode. Major changes in storing configuration.

This commit is contained in:
Gunnar Skjold
2020-05-03 16:29:38 +02:00
parent 1ea9da22c7
commit 2858123c1b
23 changed files with 1472 additions and 1232 deletions

View File

@@ -4,6 +4,7 @@
#include "root/index_html.h"
#include "root/index_js.h"
#include "root/setup_html.h"
#include "root/configmeter_html.h"
#include "root/configwifi_html.h"
#include "root/configmqtt_html.h"
@@ -17,8 +18,9 @@
#include "Base64.h"
AmsWebServer::AmsWebServer(RemoteDebug* Debug) {
AmsWebServer::AmsWebServer(RemoteDebug* Debug, HwTools* hw) {
this->debugger = Debug;
this->hw = hw;
}
void AmsWebServer::setup(AmsConfiguration* config, MQTTClient* mqtt) {
@@ -26,6 +28,7 @@ void AmsWebServer::setup(AmsConfiguration* config, MQTTClient* mqtt) {
this->mqtt = mqtt;
server.on("/", HTTP_GET, std::bind(&AmsWebServer::indexHtml, this));
server.on("/", HTTP_POST, std::bind(&AmsWebServer::handleSetup, this));
server.on("/index.js", HTTP_GET, std::bind(&AmsWebServer::indexJs, this));
server.on("/config-meter", HTTP_GET, std::bind(&AmsWebServer::configMeterHtml, this));
server.on("/config-wifi", HTTP_GET, std::bind(&AmsWebServer::configWifiHtml, this));
@@ -38,7 +41,8 @@ void AmsWebServer::setup(AmsConfiguration* config, MQTTClient* mqtt) {
server.on("/save", HTTP_POST, std::bind(&AmsWebServer::handleSave, this));
server.on("/config-system", HTTP_GET, std::bind(&AmsWebServer::configSystemHtml, this));
server.on("/config-system", HTTP_POST, std::bind(&AmsWebServer::uploadPost, this), std::bind(&AmsWebServer::configSystemUpload, this));
server.on("/firmware", HTTP_GET, std::bind(&AmsWebServer::firmwareHtml, this));
server.on("/firmware", HTTP_POST, std::bind(&AmsWebServer::uploadPost, this), std::bind(&AmsWebServer::firmwareUpload, this));
server.on("/restart-wait", HTTP_GET, std::bind(&AmsWebServer::restartWaitHtml, this));
server.on("/is-alive", HTTP_GET, std::bind(&AmsWebServer::isAliveCheck, this));
@@ -110,62 +114,64 @@ bool AmsWebServer::checkSecurity(byte level) {
void AmsWebServer::indexHtml() {
printD("Serving /index.html over http...");
if(!checkSecurity(2))
return;
String html;
if(WiFi.getMode() == WIFI_AP) {
html = String((const __FlashStringHelper*) SETUP_HTML);
html.replace("${version}", VERSION);
} else {
if(!checkSecurity(2))
return;
String html = String((const __FlashStringHelper*) INDEX_HTML);
html.replace("${version}", VERSION);
html = String((const __FlashStringHelper*) INDEX_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
double u1 = data.getL1Voltage();
double u2 = data.getL2Voltage();
double u3 = data.getL3Voltage();
double i1 = data.getL1Current();
double i2 = data.getL2Current();
double i3 = data.getL3Current();
double tpi = data.getActiveImportCounter();
double tpo = data.getActiveExportCounter();
double tqi = data.getReactiveImportCounter();
double tqo = data.getReactiveExportCounter();
html.replace("${data.P}", String(data.getActiveImportPower()));
html.replace("${data.PO}", String(data.getActiveExportPower()));
html.replace("${display.export}", config->getProductionCapacity() > 0 ? "" : "none");
html.replace("${text.import}", config->getProductionCapacity() > 0 ? "Import" : "Consumption");
html.replace("${data.U1}", u1 > 0 ? String(u1, 1) : "");
html.replace("${data.I1}", u1 > 0 ? String(i1, 1) : "");
html.replace("${display.P1}", u1 > 0 ? "" : "none");
html.replace("${data.U2}", u2 > 0 ? String(u2, 1) : "");
html.replace("${data.I2}", u2 > 0 ? String(i2, 1) : "");
html.replace("${display.P2}", u2 > 0 ? "" : "none");
html.replace("${data.U3}", u3 > 0 ? String(u3, 1) : "");
html.replace("${data.I3}", u3 > 0 ? String(i3, 1) : "");
html.replace("${display.P3}", u3 > 0 ? "" : "none");
html.replace("${data.tPI}", tpi > 0 ? String(tpi, 1) : "");
html.replace("${data.tPO}", tpi > 0 ? String(tpo, 1) : "");
html.replace("${data.tQI}", tpi > 0 ? String(tqi, 1) : "");
html.replace("${data.tQO}", tpi > 0 ? String(tqo, 1) : "");
html.replace("${display.accumulative}", tpi > 0 ? "" : "none");
double vcc = hw->getVcc();
html.replace("${vcc}", vcc > 0 ? String(vcc, 2) : "");
double temp = hw->getTemperature();
html.replace("${temp}", temp > 0 ? String(temp, 1) : "");
html.replace("${display.temp}", temp != DEVICE_DISCONNECTED_C ? "" : "none");
int rssi = hw->getWifiRssi();
html.replace("${wifi.rssi}", vcc > 0 ? String(rssi) : "");
html.replace("${wifi.channel}", WiFi.channel() > 0 ? String(WiFi.channel()) : "");
html.replace("${wifi.ssid}", !WiFi.SSID().isEmpty() ? String(WiFi.SSID()) : "");
}
double u1 = data.getL1Voltage();
double u2 = data.getL2Voltage();
double u3 = data.getL3Voltage();
double i1 = data.getL1Current();
double i2 = data.getL2Current();
double i3 = data.getL3Current();
double tpi = data.getActiveImportCounter();
double tpo = data.getActiveExportCounter();
double tqi = data.getReactiveImportCounter();
double tqo = data.getReactiveExportCounter();
html.replace("${data.P}", String(data.getActiveImportPower()));
html.replace("${data.PO}", String(data.getActiveExportPower()));
html.replace("${display.export}", config->getProductionCapacity() > 0 ? "" : "none");
html.replace("${text.import}", config->getProductionCapacity() > 0 ? "Import" : "Consumption");
html.replace("${data.U1}", u1 > 0 ? String(u1, 1) : "");
html.replace("${data.I1}", u1 > 0 ? String(i1, 1) : "");
html.replace("${display.P1}", u1 > 0 ? "" : "none");
html.replace("${data.U2}", u2 > 0 ? String(u2, 1) : "");
html.replace("${data.I2}", u2 > 0 ? String(i2, 1) : "");
html.replace("${display.P2}", u2 > 0 ? "" : "none");
html.replace("${data.U3}", u3 > 0 ? String(u3, 1) : "");
html.replace("${data.I3}", u3 > 0 ? String(i3, 1) : "");
html.replace("${display.P3}", u3 > 0 ? "" : "none");
html.replace("${data.tPI}", tpi > 0 ? String(tpi, 1) : "");
html.replace("${data.tPO}", tpi > 0 ? String(tpo, 1) : "");
html.replace("${data.tQI}", tpi > 0 ? String(tqi, 1) : "");
html.replace("${data.tQO}", tpi > 0 ? String(tqo, 1) : "");
html.replace("${display.accumulative}", tpi > 0 ? "" : "none");
double vcc = hw.getVcc();
html.replace("${vcc}", vcc > 0 ? String(vcc, 2) : "");
double temp = hw.getTemperature();
html.replace("${temp}", temp > 0 ? String(temp, 1) : "");
html.replace("${display.temp}", temp != DEVICE_DISCONNECTED_C ? "" : "none");
int rssi = hw.getWifiRssi();
html.replace("${wifi.rssi}", vcc > 0 ? String(rssi) : "");
html.replace("${wifi.channel}", WiFi.channel() > 0 ? String(WiFi.channel()) : "");
html.replace("${wifi.ssid}", !WiFi.SSID().isEmpty() ? String(WiFi.SSID()) : "");
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
server.sendHeader("Expires", "-1");
@@ -190,10 +196,6 @@ void AmsWebServer::configMeterHtml() {
String html = String((const __FlashStringHelper*) CONFIGMETER_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
@@ -224,16 +226,12 @@ void AmsWebServer::configWifiHtml() {
String html = String((const __FlashStringHelper*) CONFIGWIFI_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
html.replace("${config.wifiSsid}", config->getWifiSsid());
html.replace("${config.wifiPassword}", config->getWifiPassword());
html.replace("${config.wifiIpType1}", config->getWifiIp().isEmpty() ? "" : "selected");
html.replace("${config.wifiIpType1}", strlen(config->getWifiIp()) > 0 ? "selected" : "");
html.replace("${config.wifiIp}", config->getWifiIp());
html.replace("${config.wifiGw}", config->getWifiGw());
html.replace("${config.wifiSubnet}", config->getWifiSubnet());
@@ -254,14 +252,10 @@ void AmsWebServer::configMqttHtml() {
String html = String((const __FlashStringHelper*) CONFIGMQTT_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
html.replace("${config.mqtt}", config->getMqttHost() == 0 ? "" : "checked");
html.replace("${config.mqtt}", strlen(config->getMqttHost()) == 0 ? "" : "checked");
html.replace("${config.mqttHost}", config->getMqttHost());
if(config->getMqttPort() > 0) {
html.replace("${config.mqttPort}", String(config->getMqttPort()));
@@ -311,10 +305,6 @@ void AmsWebServer::configWebHtml() {
String html = String((const __FlashStringHelper*) CONFIGWEB_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
@@ -414,10 +404,10 @@ void AmsWebServer::dataJson() {
json["maxPower"] = maxPwr;
json["meterType"] = config->getMeterType();
json["uptime_seconds"] = millis64() / 1000;
double vcc = hw.getVcc();
double vcc = hw->getVcc();
json["vcc"] = serialized(String(vcc, 3));
double temp = hw.getTemperature();
double temp = hw->getTemperature();
json["temp"] = serialized(String(temp, 2));
json.createNestedObject("wifi");
@@ -455,7 +445,7 @@ void AmsWebServer::dataJson() {
json["status"]["han"] = hanStatus;
String wifiStatus;
if(config->getWifiSsid().isEmpty()) {
if(strlen(config->getWifiSsid()) == 0) {
wifiStatus = "secondary";
} else if(rssi > -75) {
wifiStatus = "success";
@@ -467,7 +457,7 @@ void AmsWebServer::dataJson() {
json["status"]["wifi"] = wifiStatus;
String mqttStatus;
if(config->getMqttHost().isEmpty()) {
if(strlen(config->getMqttHost()) == 0) {
mqttStatus = "secondary";
} else if(mqtt->connected()) {
mqttStatus = "success";
@@ -491,6 +481,100 @@ void AmsWebServer::dataJson() {
server.send(200, "application/json", jsonStr);
}
void AmsWebServer::handleSetup() {
if(!server.hasArg("wifiSsid") || server.arg("wifiSsid").isEmpty() || !server.hasArg("wifiPassword") || server.arg("wifiPassword").isEmpty()) {
server.sendHeader("Location", String("/"), true);
server.send (302, "text/plain", "");
} else {
config->setVccMultiplier(1.0);
config->setVccBootLimit(0);
switch(server.arg("board").toInt()) {
case 0: // roarfred
config->setHanPin(3);
config->setApPin(0);
config->setLedPin(2);
config->setLedInverted(true);
config->setTempSensorPin(5);
break;
case 1: // Arnio Kamstrup
config->setHanPin(3);
config->setApPin(0);
config->setLedPin(2);
config->setLedInverted(true);
config->setTempSensorPin(5);
config->setLedPinRed(13);
config->setLedPinGreen(14);
config->setLedRgbInverted(true);
break;
case 2: // spenceme
config->setHanPin(3);
config->setApPin(0);
config->setLedPin(2);
config->setLedInverted(true);
config->setTempSensorPin(5);
config->setVccBootLimit(3.3);
break;
case 101: // D1
config->setHanPin(5);
config->setApPin(4);
config->setLedPin(2);
config->setLedInverted(true);
config->setTempSensorPin(14);
config->setVccMultiplier(1.1);
break;
case 199: // ESP8266
config->setHanPin(3);
config->setLedPin(2);
config->setLedInverted(true);
break;
case 201: // D32
config->setHanPin(16);
config->setApPin(4);
config->setLedPin(5);
config->setLedInverted(true);
config->setTempSensorPin(14);
config->setVccPin(35);
config->setVccMultiplier(2.25);
break;
case 202: // Feather ESP32
config->setHanPin(16);
config->setLedPin(2);
config->setLedInverted(false);
config->setTempSensorPin(14);
break;
case 299: // ESP32
config->setHanPin(16);
config->setLedPin(2);
config->setLedInverted(true);
config->setTempSensorPin(14);
break;
}
config->setMeterType(server.arg("meterType").toInt());
config->setWifiSsid(server.arg("wifiSsid").c_str());
config->setWifiPassword(server.arg("wifiPassword").c_str());
if(server.hasArg("wifiIpType") && server.arg("wifiIpType").toInt() == 1) {
config->setWifiIp(server.arg("wifiIp").c_str());
config->setWifiGw(server.arg("wifiGw").c_str());
config->setWifiSubnet(server.arg("wifiSubnet").c_str());
config->setWifiDns1(server.arg("wifiDns1").c_str());
} else {
config->clearWifiIp();
}
if(server.hasArg("wifiHostname") && !server.arg("wifiHostname").isEmpty()) {
config->setWifiHostname(server.arg("wifiHostname").c_str());
}
if(config->save()) {
performRestart = true;
server.sendHeader("Location","/restart-wait");
server.send(303);
} else {
printE("Error saving configuration");
String html = "<html><body><h1>Error saving configuration!</h1></form>";
server.send(500, "text/html", html);
}
}
}
void AmsWebServer::handleSave() {
String temp;
@@ -502,30 +586,30 @@ void AmsWebServer::handleSave() {
}
if(server.hasArg("wifiConfig") && server.arg("wifiConfig") == "true") {
config->setWifiSsid(server.arg("wifiSsid"));
config->setWifiPassword(server.arg("wifiPassword"));
config->setWifiSsid(server.arg("wifiSsid").c_str());
config->setWifiPassword(server.arg("wifiPassword").c_str());
if(server.hasArg("wifiIpType") && server.arg("wifiIpType").toInt() == 1) {
config->setWifiIp(server.arg("wifiIp"));
config->setWifiGw(server.arg("wifiGw"));
config->setWifiSubnet(server.arg("wifiSubnet"));
config->setWifiDns1(server.arg("wifiDns1"));
config->setWifiDns2(server.arg("wifiDns2"));
config->setWifiIp(server.arg("wifiIp").c_str());
config->setWifiGw(server.arg("wifiGw").c_str());
config->setWifiSubnet(server.arg("wifiSubnet").c_str());
config->setWifiDns1(server.arg("wifiDns1").c_str());
config->setWifiDns2(server.arg("wifiDns2").c_str());
} else {
config->clearWifiIp();
}
config->setWifiHostname(server.arg("wifiHostname"));
config->setWifiHostname(server.arg("wifiHostname").c_str());
}
if(server.hasArg("mqttConfig") && server.arg("mqttConfig") == "true") {
if(server.hasArg("mqtt") && server.arg("mqtt") == "true") {
config->setMqttHost(server.arg("mqttHost"));
config->setMqttHost(server.arg("mqttHost").c_str());
int port = server.arg("mqttPort").toInt();
config->setMqttPort(port == 0 ? 1883 : port);
config->setMqttClientId(server.arg("mqttClientId"));
config->setMqttPublishTopic(server.arg("mqttPublishTopic"));
config->setMqttSubscribeTopic(server.arg("mqttSubscribeTopic"));
config->setMqttUser(server.arg("mqttUser"));
config->setMqttPassword(server.arg("mqttPassword"));
config->setMqttClientId(server.arg("mqttClientId").c_str());
config->setMqttPublishTopic(server.arg("mqttPublishTopic").c_str());
config->setMqttSubscribeTopic(server.arg("mqttSubscribeTopic").c_str());
config->setMqttUser(server.arg("mqttUser").c_str());
config->setMqttPassword(server.arg("mqttPassword").c_str());
config->setMqttPayloadFormat(server.arg("mqttPayloadFormat").toInt());
config->setMqttSsl(server.arg("mqttSsl") == "true");
} else {
@@ -536,8 +620,8 @@ void AmsWebServer::handleSave() {
if(server.hasArg("authConfig") && server.arg("authConfig") == "true") {
config->setAuthSecurity((byte)server.arg("authSecurity").toInt());
if(config->getAuthSecurity() > 0) {
config->setAuthUser(server.arg("authUser"));
config->setAuthPassword(server.arg("authPassword"));
config->setAuthUser(server.arg("authUser").c_str());
config->setAuthPassword(server.arg("authPassword").c_str());
debugger->setPassword(config->getAuthPassword());
} else {
debugger->setPassword("");
@@ -546,6 +630,19 @@ void AmsWebServer::handleSave() {
}
if(server.hasArg("sysConfig") && server.arg("sysConfig") == "true") {
config->setHanPin(server.arg("hanPin").toInt());
config->setLedPin(server.arg("ledPin").toInt());
config->setLedInverted(server.hasArg("ledInverted") && server.arg("ledInverted") == "true");
config->setLedPinRed(server.arg("ledPinRed").toInt());
config->setLedPinGreen(server.arg("ledPinGreen").toInt());
config->setLedPinBlue(server.arg("ledPinBlue").toInt());
config->setLedRgbInverted(server.hasArg("ledRgbInverted") && server.arg("ledRgbInverted") == "true");
config->setApPin(server.arg("apPin").toInt());
config->setTempSensorPin(server.arg("tempSensorPin").toInt());
config->setVccPin(server.arg("vccPin").toInt());
config->setVccMultiplier(server.arg("vccMultiplier").toDouble());
config->setVccBootLimit(server.arg("vccBootLimit").toDouble());
config->setDebugTelnet(server.hasArg("debugTelnet") && server.arg("debugTelnet") == "true");
config->setDebugSerial(server.hasArg("debugSerial") && server.arg("debugSerial") == "true");
config->setDebugLevel(server.arg("debugLevel").toInt());
@@ -575,6 +672,12 @@ void AmsWebServer::handleSave() {
} else {
server.sendHeader("Location", String("/"), true);
server.send (302, "text/plain", "");
hw->setLed(config->getLedPin(), config->isLedInverted());
hw->setLedRgb(config->getLedPinRed(), config->getLedPinGreen(), config->getLedPinBlue(), config->isLedRgbInverted());
hw->setTempSensorPin(config->getTempSensorPin());
hw->setVccPin(config->getVccPin());
hw->setVccMultiplier(config->getVccMultiplier());
}
} else {
printE("Error saving configuration");
@@ -592,9 +695,26 @@ void AmsWebServer::configSystemHtml() {
String html = String((const __FlashStringHelper*) CONFIGSYSTEM_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
#if defined(ESP32)
html.replace("${gpio.max}", "39");
#else
html.replace("${gpio.max}", "16");
#endif
html.replace("${options.han}", getSerialSelectOptions(config->getHanPin()));
html.replace("${config.ledPin}", config->getLedPin() == 0xFF ? "" : String(config->getLedPin()));
html.replace("${config.ledInverted}", String(config->isLedInverted()) ? "checked" : "");
html.replace("${config.ledPinRed}", config->getLedPinRed() == 0xFF ? "" : String(config->getLedPinRed()));
html.replace("${config.ledPinGreen}", config->getLedPinGreen() == 0xFF ? "" : String(config->getLedPinGreen()));
html.replace("${config.ledPinBlue}", config->getLedPinBlue() == 0xFF ? "" : String(config->getLedPinBlue()));
html.replace("${config.ledRgbInverted}", String(config->isLedRgbInverted() ? "checked" : ""));
html.replace("${config.apPin}", config->getApPin() == 0xFF ? "" : String(config->getApPin()));
html.replace("${config.tempSensorPin}", config->getTempSensorPin() == 0xFF ? "" : String(config->getTempSensorPin()));
html.replace("${config.vccPin}", config->getVccPin() == 0xFF ? "" : String(config->getVccPin()));
html.replace("${config.vccMultiplier}", String(config->getVccMultiplier()));
html.replace("${config.vccBootLimit}", String(config->getVccBootLimit()));
html.replace("${config.debugTelnet}", config->isDebugTelnet() ? "checked" : "");
html.replace("${config.debugSerial}", config->isDebugSerial() ? "checked" : "");
@@ -610,6 +730,44 @@ void AmsWebServer::configSystemHtml() {
server.send(200, "text/html", html);
}
String AmsWebServer::getSerialSelectOptions(int selected) {
String gpioOptions;
if(selected == 3) {
gpioOptions += "<option value=\"3\" selected>UART0</option>\n";
} else {
gpioOptions += "<option value=\"3\">UART0</option>\n";
}
#if defined(ESP32)
int numGpio = 24;
int gpios[] = {4,5,6,7,8,10,11,12,13,14,15,17,18,19,21,22,23,25,32,33,34,35,36,39};
if(selected == 9) {
gpioOptions += "<option value=\"9\" selected>UART1</option>\n";
} else {
gpioOptions += "<option value=\"9\">UART1</option>\n";
}
if(selected == 16) {
gpioOptions += "<option value=\"16\" selected>UART2</option>\n";
} else {
gpioOptions += "<option value=\"16\">UART2</option>\n";
}
#elif defined(ESP8266)
int numGpio = 9;
int gpios[] = {4,5,9,10,12,13,14,15,16};
#endif
for(int i = 0; i < numGpio; i++) {
int gpio = gpios[i];
char buffer [16];
sprintf(buffer, "%02u", gpio);
if(gpio == selected) {
gpioOptions += "<option value=\"" + String(gpio) + "\" selected>GPIO" + buffer + "</option>\n";
} else {
gpioOptions += "<option value=\"" + String(gpio) + "\">GPIO" + buffer + "</option>\n";
}
}
return gpioOptions;
}
void AmsWebServer::uploadPost() {
server.send(200);
}
@@ -648,7 +806,13 @@ void AmsWebServer::deleteFile(const char* path) {
}
}
void AmsWebServer::configSystemUpload() {
void AmsWebServer::firmwareHtml() {
printD("Serving /firmware.html over http...");
uploadHtml("CA file", "/firmware", "mqtt");
}
void AmsWebServer::firmwareUpload() {
HTTPUpload& upload = server.upload();
if(upload.status == UPLOAD_FILE_START) {
String filename = upload.filename;
@@ -676,7 +840,7 @@ void AmsWebServer::restartWaitHtml() {
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
if(config->getWifiIp().isEmpty() && WiFi.getMode() != WIFI_AP) {
if(strlen(config->getWifiIp()) == 0 && WiFi.getMode() != WIFI_AP) {
html.replace("${ip}", WiFi.localIP().toString());
} else {
html.replace("${ip}", config->getWifiIp());
@@ -713,10 +877,6 @@ void AmsWebServer::uploadHtml(const char* label, const char* action, const char*
html.replace("${form.action}", action);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
html.replace("${menu." + String(menu) + ".class}", "active");
html.replace("${menu.meter.class}", "");
html.replace("${menu.wifi.class}", "");
@@ -737,10 +897,6 @@ void AmsWebServer::deleteHtml(const char* label, const char* action, const char*
html.replace("${form.action}", action);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
html.replace("${menu." + String(menu) + ".class}", "active");
html.replace("${menu.meter.class}", "");
html.replace("${menu.wifi.class}", "");
@@ -759,7 +915,6 @@ void AmsWebServer::deleteHtml(const char* label, const char* action, const char*
void AmsWebServer::mqttCa() {
printD("Serving /mqtt-ca.html over http...");
String html;
if(SPIFFS.begin()) {
if(SPIFFS.exists(FILE_MQTT_CA)) {
deleteHtml("CA file", "/mqtt-ca/delete", "mqtt");
@@ -797,7 +952,6 @@ void AmsWebServer::mqttCaDelete() {
void AmsWebServer::mqttCert() {
printD("Serving /mqtt-cert.html over http...");
String html;
if(SPIFFS.begin()) {
if(SPIFFS.exists(FILE_MQTT_CERT)) {
deleteHtml("Certificate", "/mqtt-cert/delete", "mqtt");
@@ -835,7 +989,6 @@ void AmsWebServer::mqttCertDelete() {
void AmsWebServer::mqttKey() {
printD("Serving /mqtt-key.html over http...");
String html;
if(SPIFFS.begin()) {
if(SPIFFS.exists(FILE_MQTT_KEY)) {
deleteHtml("Private key", "/mqtt-key/delete", "mqtt");