mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-18 17:26:46 +00:00
Added DNS to static IP config. Added hostname to config. Added mDNS
This commit is contained in:
parent
26634f96b0
commit
d747c84a14
12
.github/workflows/release.yml
vendored
12
.github/workflows/release.yml
vendored
@ -52,7 +52,7 @@ jobs:
|
||||
draft: false
|
||||
prerelease: false
|
||||
- name: Upload hw1esp12e binary to release
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
@ -61,7 +61,7 @@ jobs:
|
||||
asset_name: ams2mqtt-hw1esp12e-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload esp12e binary to release
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
@ -70,7 +70,7 @@ jobs:
|
||||
asset_name: ams2mqtt-esp12e-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload d1mini binary to release
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
@ -79,7 +79,7 @@ jobs:
|
||||
asset_name: ams2mqtt-d1mini-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload esp32 binary to release
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
@ -88,7 +88,7 @@ jobs:
|
||||
asset_name: ams2mqtt-esp32-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload lolind32 binary to release
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
@ -97,7 +97,7 @@ jobs:
|
||||
asset_name: ams2mqtt-lolind32-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload featheresp32 binary to release
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
||||
@ -45,10 +45,39 @@ void AmsConfiguration::setWifiSubnet(String wifiSubnet) {
|
||||
this->wifiSubnet = String(wifiSubnet);
|
||||
}
|
||||
|
||||
String AmsConfiguration::getWifiDns1() {
|
||||
return wifiDns1;
|
||||
}
|
||||
|
||||
void AmsConfiguration::setWifiDns1(String wifiDns1) {
|
||||
wifiChanged |= this->wifiDns1 != wifiDns1;
|
||||
this->wifiDns1 = wifiDns1;
|
||||
}
|
||||
|
||||
String AmsConfiguration::getWifiDns2() {
|
||||
return wifiDns2;
|
||||
}
|
||||
|
||||
void AmsConfiguration::setWifiDns2(String wifiDns2) {
|
||||
wifiChanged |= this->wifiDns2 != wifiDns2;
|
||||
this->wifiDns2 = wifiDns2;
|
||||
}
|
||||
|
||||
String AmsConfiguration::getWifiHostname() {
|
||||
return wifiHostname;
|
||||
}
|
||||
|
||||
void AmsConfiguration::setWifiHostname(String wifiHostname) {
|
||||
wifiChanged |= this->wifiHostname != wifiHostname;
|
||||
this->wifiHostname = wifiHostname;
|
||||
}
|
||||
|
||||
void AmsConfiguration::clearWifiIp() {
|
||||
setWifiIp("");
|
||||
setWifiGw("");
|
||||
setWifiSubnet("");
|
||||
setWifiDns1("");
|
||||
setWifiDns2("");
|
||||
}
|
||||
|
||||
bool AmsConfiguration::isWifiChanged() {
|
||||
@ -214,9 +243,11 @@ void AmsConfiguration::setProductionCapacity(int productionCapacity) {
|
||||
|
||||
|
||||
bool AmsConfiguration::hasConfig() {
|
||||
EEPROM.begin(EEPROM_SIZE);
|
||||
int configVersion = EEPROM.read(EEPROM_CONFIG_ADDRESS);
|
||||
EEPROM.end();
|
||||
if(configVersion == 0) {
|
||||
EEPROM.begin(EEPROM_SIZE);
|
||||
configVersion = EEPROM.read(EEPROM_CONFIG_ADDRESS);
|
||||
EEPROM.end();
|
||||
}
|
||||
switch(configVersion) {
|
||||
case 71:
|
||||
case 72:
|
||||
@ -229,6 +260,10 @@ bool AmsConfiguration::hasConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
int AmsConfiguration::getConfigVersion() {
|
||||
return configVersion;
|
||||
}
|
||||
|
||||
bool AmsConfiguration::load() {
|
||||
int address = EEPROM_CONFIG_ADDRESS;
|
||||
bool success = false;
|
||||
@ -451,13 +486,23 @@ bool AmsConfiguration::loadConfig81(int address) {
|
||||
setWifiSsid(temp);
|
||||
address += readString(address, &temp);
|
||||
setWifiPassword(temp);
|
||||
address += readString(address, &temp);
|
||||
setWifiIp(temp);
|
||||
address += readString(address, &temp);
|
||||
setWifiGw(temp);
|
||||
address += readString(address, &temp);
|
||||
setWifiSubnet(temp);
|
||||
|
||||
bool staticIp = false;
|
||||
address += readBool(address, &staticIp);
|
||||
if(staticIp) {
|
||||
address += readString(address, &temp);
|
||||
setWifiIp(temp);
|
||||
address += readString(address, &temp);
|
||||
setWifiGw(temp);
|
||||
address += readString(address, &temp);
|
||||
setWifiSubnet(temp);
|
||||
address += readString(address, &temp);
|
||||
setWifiDns1(temp);
|
||||
address += readString(address, &temp);
|
||||
setWifiDns2(temp);
|
||||
}
|
||||
address += readString(address, &temp);
|
||||
setWifiHostname(temp);
|
||||
bool mqtt = false;
|
||||
address += readBool(address, &mqtt);
|
||||
if(mqtt) {
|
||||
@ -526,17 +571,25 @@ bool AmsConfiguration::save() {
|
||||
|
||||
address += saveString(address, wifiSsid.c_str());
|
||||
address += saveString(address, wifiPassword.c_str());
|
||||
address += saveString(address, wifiIp.c_str());
|
||||
address += saveString(address, wifiGw.c_str());
|
||||
address += saveString(address, wifiSubnet.c_str());
|
||||
if(mqttHost) {
|
||||
if(!wifiIp.isEmpty()) {
|
||||
address += saveBool(address, true);
|
||||
address += saveString(address, wifiIp.c_str());
|
||||
address += saveString(address, wifiGw.c_str());
|
||||
address += saveString(address, wifiSubnet.c_str());
|
||||
address += saveString(address, wifiDns1.c_str());
|
||||
address += saveString(address, wifiDns2.c_str());
|
||||
} else {
|
||||
address += saveBool(address, false);
|
||||
}
|
||||
address += saveString(address, wifiHostname.c_str());
|
||||
if(!mqttHost.isEmpty()) {
|
||||
address += saveBool(address, true);
|
||||
address += saveString(address, mqttHost.c_str());
|
||||
address += saveInt(address, mqttPort);
|
||||
address += saveString(address, mqttClientId.c_str());
|
||||
address += saveString(address, mqttPublishTopic.c_str());
|
||||
address += saveString(address, mqttSubscribeTopic.c_str());
|
||||
if (mqttUser) {
|
||||
if (!mqttUser.isEmpty()) {
|
||||
address += saveBool(address, true);
|
||||
address += saveString(address, mqttUser.c_str());
|
||||
address += saveString(address, mqttPassword.c_str());
|
||||
@ -562,6 +615,8 @@ bool AmsConfiguration::save() {
|
||||
bool success = EEPROM.commit();
|
||||
EEPROM.end();
|
||||
|
||||
configVersion = EEPROM_CHECK_SUM;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@ -656,13 +711,15 @@ void AmsConfiguration::print(Stream* debugger)
|
||||
debugger->printf("WiFi SSID: %s\r\n", this->getWifiSsid().c_str());
|
||||
debugger->printf("WiFi Psk: %s\r\n", this->getWifiPassword().c_str());
|
||||
|
||||
if(getWifiIp()) {
|
||||
if(!getWifiIp().isEmpty()) {
|
||||
debugger->printf("IP: %s\r\n", this->getWifiIp().c_str());
|
||||
debugger->printf("Gateway: %s\r\n", this->getWifiGw().c_str());
|
||||
debugger->printf("Subnet: %s\r\n", this->getWifiSubnet().c_str());
|
||||
debugger->printf("Subnet: %s\r\n", this->getWifiSubnet().c_str());
|
||||
debugger->printf("Primary DNS: %s\r\n", this->getWifiDns1().c_str());
|
||||
debugger->printf("Secondary DNS: %s\r\n", this->getWifiDns2().c_str());
|
||||
}
|
||||
|
||||
if(getMqttHost()) {
|
||||
if(!getMqttHost().isEmpty()) {
|
||||
debugger->printf("mqttHost: %s\r\n", this->getMqttHost().c_str());
|
||||
debugger->printf("mqttPort: %i\r\n", this->getMqttPort());
|
||||
debugger->printf("mqttClientID: %s\r\n", this->getMqttClientId().c_str());
|
||||
@ -673,6 +730,7 @@ void AmsConfiguration::print(Stream* debugger)
|
||||
debugger->printf("mqttUser: %s\r\n", this->getMqttUser().c_str());
|
||||
debugger->printf("mqttPass: %s\r\n", this->getMqttPassword().c_str());
|
||||
}
|
||||
debugger->printf("payload format: %i\r\n", this->getMqttPayloadFormat());
|
||||
}
|
||||
|
||||
if (this->getAuthSecurity()) {
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
class AmsConfiguration {
|
||||
public:
|
||||
bool hasConfig();
|
||||
int getConfigVersion();
|
||||
|
||||
bool load();
|
||||
bool save();
|
||||
|
||||
@ -19,6 +21,12 @@ public:
|
||||
void setWifiGw(String wifiGw);
|
||||
String getWifiSubnet();
|
||||
void setWifiSubnet(String wifiSubnet);
|
||||
String getWifiDns1();
|
||||
void setWifiDns1(String wifiDns1);
|
||||
String getWifiDns2();
|
||||
void setWifiDns2(String wifiDns1);
|
||||
String getWifiHostname();
|
||||
void setWifiHostname(String wifiHostname);
|
||||
void clearWifiIp();
|
||||
|
||||
bool isWifiChanged();
|
||||
@ -67,11 +75,16 @@ public:
|
||||
protected:
|
||||
|
||||
private:
|
||||
int configVersion;
|
||||
|
||||
String wifiSsid;
|
||||
String wifiPassword;
|
||||
String wifiIp;
|
||||
String wifiGw;
|
||||
String wifiSubnet;
|
||||
String wifiDns1;
|
||||
String wifiDns2;
|
||||
String wifiHostname;
|
||||
bool wifiChanged;
|
||||
|
||||
String mqttHost;
|
||||
|
||||
@ -8,8 +8,10 @@
|
||||
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#elif defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#include <ESPmDNS.h>
|
||||
#include "SPIFFS.h"
|
||||
#include "Update.h"
|
||||
#endif
|
||||
|
||||
@ -166,6 +166,16 @@ void setup() {
|
||||
}
|
||||
}
|
||||
|
||||
if(config.getConfigVersion() < 81) {
|
||||
uint16_t chipId;
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
chipId = ESP.getEfuseMac();
|
||||
#else
|
||||
chipId = ESP.getChipId();
|
||||
#endif
|
||||
config.setWifiHostname(String("ams-") + String(chipId, HEX));
|
||||
}
|
||||
|
||||
if(config.hasConfig()) {
|
||||
if(debugger) config.print(debugger);
|
||||
WiFi_connect();
|
||||
@ -285,6 +295,10 @@ void loop() {
|
||||
if(debugger) {
|
||||
debugger->println("Successfully connected to WiFi!");
|
||||
debugger->println(WiFi.localIP());
|
||||
if(!config.getWifiHostname().isEmpty()) {
|
||||
MDNS.begin(config.getWifiHostname().c_str());
|
||||
MDNS.addService("http", "tcp", 80);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!config.getMqttHost().isEmpty()) {
|
||||
@ -573,17 +587,27 @@ void WiFi_connect() {
|
||||
}
|
||||
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
MDNS.end();
|
||||
WiFi.disconnect();
|
||||
yield();
|
||||
|
||||
WiFi.enableAP(false);
|
||||
WiFi.mode(WIFI_STA);
|
||||
if(!config.getWifiIp().isEmpty()) {
|
||||
IPAddress ip, gw, sn(255,255,255,0);
|
||||
IPAddress ip, gw, sn(255,255,255,0), dns1, dns2;
|
||||
ip.fromString(config.getWifiIp());
|
||||
gw.fromString(config.getWifiGw());
|
||||
sn.fromString(config.getWifiSubnet());
|
||||
WiFi.config(ip, gw, sn);
|
||||
dns1.fromString(config.getWifiDns1());
|
||||
dns2.fromString(config.getWifiDns2());
|
||||
WiFi.config(ip, gw, sn, dns1, dns2);
|
||||
}
|
||||
if(!config.getWifiHostname().isEmpty()) {
|
||||
#if defined(ESP8266)
|
||||
WiFi.hostname(config.getWifiHostname());
|
||||
#elif defined(ESP32)
|
||||
WiFi.setHostname(config.getWifiHostname().c_str());
|
||||
#endif
|
||||
}
|
||||
WiFi.begin(config.getWifiSsid().c_str(), config.getWifiPassword().c_str());
|
||||
yield();
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include "root/configmqtt_html.h"
|
||||
#include "root/configweb_html.h"
|
||||
#include "root/configsystem_html.h"
|
||||
#include "root/firmwarewait_html.h"
|
||||
#include "root/restartwait_html.h"
|
||||
#include "root/boot_css.h"
|
||||
#include "root/gaugemeter_js.h"
|
||||
|
||||
@ -32,7 +32,8 @@ void AmsWebServer::setup(AmsConfiguration* config, Stream* debugger, MQTTClient*
|
||||
|
||||
server.on("/config-system", HTTP_GET, std::bind(&AmsWebServer::configSystemHtml, this));
|
||||
server.on("/config-system", HTTP_POST, std::bind(&AmsWebServer::configSystemPost, this), std::bind(&AmsWebServer::configSystemUpload, this));
|
||||
server.on("/firmware-wait", HTTP_GET, std::bind(&AmsWebServer::firmwareWaitHtml, this));
|
||||
server.on("/restart-wait", HTTP_GET, std::bind(&AmsWebServer::restartWaitHtml, this));
|
||||
server.on("/is-alive", HTTP_GET, std::bind(&AmsWebServer::isAliveCheck, this));
|
||||
|
||||
server.begin(); // Web server start
|
||||
}
|
||||
@ -209,6 +210,9 @@ void AmsWebServer::configWifiHtml() {
|
||||
html.replace("${config.wifiIp}", config->getWifiIp());
|
||||
html.replace("${config.wifiGw}", config->getWifiGw());
|
||||
html.replace("${config.wifiSubnet}", config->getWifiSubnet());
|
||||
html.replace("${config.wifiDns1}", config->getWifiDns1());
|
||||
html.replace("${config.wifiDns2}", config->getWifiDns2());
|
||||
html.replace("${config.wifiHostname}", config->getWifiHostname());
|
||||
|
||||
server.setContentLength(html.length());
|
||||
server.send(200, "text/html", html);
|
||||
@ -462,9 +466,12 @@ void AmsWebServer::handleSave() {
|
||||
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"));
|
||||
} else {
|
||||
config->clearWifiIp();
|
||||
}
|
||||
config->setWifiHostname(server.arg("wifiHostname"));
|
||||
}
|
||||
|
||||
if(server.hasArg("mqttConfig") && server.arg("mqttConfig") == "true") {
|
||||
@ -499,19 +506,12 @@ void AmsWebServer::handleSave() {
|
||||
if (config->save()) {
|
||||
println("Successfully saved.");
|
||||
if(config->isWifiChanged()) {
|
||||
String html = "<html><body><h1>Successfully Saved!</h1><a href=\"/\">Go to index</a></form>";
|
||||
server.send(200, "text/html", html);
|
||||
yield();
|
||||
println("Wifi config changed, rebooting");
|
||||
delay(1000);
|
||||
#if defined(ESP8266)
|
||||
ESP.reset();
|
||||
#elif defined(ESP32)
|
||||
ESP.restart();
|
||||
#endif
|
||||
performRestart = true;
|
||||
server.sendHeader("Location","/restart-wait");
|
||||
server.send(303);
|
||||
} else {
|
||||
server.sendHeader("Location", String("/"), true);
|
||||
server.send ( 302, "text/plain", "");
|
||||
server.send (302, "text/plain", "");
|
||||
}
|
||||
} else {
|
||||
println("Error saving configuration");
|
||||
@ -567,7 +567,8 @@ void AmsWebServer::configSystemUpload() {
|
||||
firmwareFile.close();
|
||||
SPIFFS.end();
|
||||
print("handleFileUpload Size: "); println(String(upload.totalSize).c_str());
|
||||
server.sendHeader("Location","/firmware-wait");
|
||||
performRestart = true;
|
||||
server.sendHeader("Location","/restart-wait");
|
||||
server.send(303);
|
||||
} else {
|
||||
server.send(500, "text/plain", "500: couldn't create file");
|
||||
@ -575,18 +576,24 @@ void AmsWebServer::configSystemUpload() {
|
||||
}
|
||||
}
|
||||
|
||||
void AmsWebServer::firmwareWaitHtml() {
|
||||
println("Serving /firmware-wait.html over http...");
|
||||
void AmsWebServer::restartWaitHtml() {
|
||||
println("Serving /restart-wait.html over http...");
|
||||
|
||||
if(!checkSecurity(1))
|
||||
return;
|
||||
|
||||
String html = String((const __FlashStringHelper*) FIRMWAREWAIT_HTML);
|
||||
String html = String((const __FlashStringHelper*) RESTARTWAIT_HTML);
|
||||
html.replace("${version}", VERSION);
|
||||
|
||||
if(WiFi.getMode() != WIFI_AP) {
|
||||
html.replace("boot.css", BOOTSTRAP_URL);
|
||||
}
|
||||
if(config->getWifiIp().isEmpty() && WiFi.getMode() != WIFI_AP) {
|
||||
html.replace("${ip}", WiFi.localIP().toString());
|
||||
} else {
|
||||
html.replace("${ip}", config->getWifiIp());
|
||||
}
|
||||
html.replace("${hostname}", config->getWifiHostname());
|
||||
|
||||
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
server.sendHeader("Pragma", "no-cache");
|
||||
@ -595,7 +602,7 @@ void AmsWebServer::firmwareWaitHtml() {
|
||||
server.send(200, "text/html", html);
|
||||
|
||||
yield();
|
||||
if(SPIFFS.begin() && SPIFFS.exists("/firmware.bin")) {
|
||||
if(performRestart) {
|
||||
SPIFFS.end();
|
||||
println("Firmware uploaded, rebooting");
|
||||
delay(1000);
|
||||
@ -604,9 +611,15 @@ void AmsWebServer::firmwareWaitHtml() {
|
||||
#elif defined(ESP32)
|
||||
ESP.restart();
|
||||
#endif
|
||||
performRestart = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AmsWebServer::isAliveCheck() {
|
||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||
server.send(200);
|
||||
}
|
||||
|
||||
size_t AmsWebServer::print(const char* text)
|
||||
{
|
||||
if (debugger) debugger->print(text);
|
||||
|
||||
@ -43,6 +43,7 @@ private:
|
||||
Stream* debugger;
|
||||
MQTTClient* mqtt;
|
||||
File firmwareFile;
|
||||
bool performRestart = false;
|
||||
|
||||
#if defined(ESP8266)
|
||||
ESP8266WebServer server;
|
||||
@ -66,7 +67,8 @@ private:
|
||||
void configSystemHtml();
|
||||
void configSystemPost();
|
||||
void configSystemUpload();
|
||||
void firmwareWaitHtml();
|
||||
void restartWaitHtml();
|
||||
void isAliveCheck();
|
||||
|
||||
size_t print(const char* text);
|
||||
size_t println(const char* text);
|
||||
|
||||
@ -55,6 +55,12 @@
|
||||
<input type="password" class="form-control" name="wifiPassword" value="${config.wifiPassword}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<label class="col-3">Hostname</label>
|
||||
<div class="col-9">
|
||||
<input type="text" class="form-control" name="wifiHostname" value="${config.wifiHostname}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="row form-group">
|
||||
@ -67,23 +73,35 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<label class="col-3">IP</label>
|
||||
<div class="col-9">
|
||||
<label class="col-6">IP</label>
|
||||
<div class="col-6">
|
||||
<input type="text" class="form-control wifiip-config" name="wifiIp" value="${config.wifiIp}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<label class="col-6">Subnet</label>
|
||||
<div class="col-6">
|
||||
<input type="text" class="form-control wifiip-config" name="wifiSubnet" value="${config.wifiSubnet}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="row form-group">
|
||||
<label class="col-3">Subnet</label>
|
||||
<div class="col-9">
|
||||
<input type="text" class="form-control wifiip-config" name="wifiSubnet" value="${config.wifiSubnet}"/>
|
||||
<label class="col-6">Gateway</label>
|
||||
<div class="col-6">
|
||||
<input type="text" class="form-control wifiip-config" name="wifiGw" value="${config.wifiGw}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<label class="col-3">Gateway</label>
|
||||
<div class="col-9">
|
||||
<input type="text" class="form-control wifiip-config" name="wifiGw" value="${config.wifiGw}"/>
|
||||
<label class="col-6">Primary DNS</label>
|
||||
<div class="col-6">
|
||||
<input type="text" class="form-control wifiip-config" name="wifiDns1" value="${config.wifiDns1}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<label class="col-6">Secondary DNS</label>
|
||||
<div class="col-6">
|
||||
<input type="text" class="form-control wifiip-config" name="wifiDns2" value="${config.wifiDns2}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<a class="nav-link" href="/config-web">Web</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="/config-system">System</a>
|
||||
<a class="nav-link" href="/config-system">System</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -39,23 +39,38 @@
|
||||
</ul>
|
||||
</header>
|
||||
<div class="my-3 p-3 bg-white rounded shadow">
|
||||
Firmware upload complete, you will be redirected to the main page when the device is finished flashing.
|
||||
Device is rebooting. You will be redirected to the main page when it is available again.
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
interval = 5000;
|
||||
var tries = 0;
|
||||
|
||||
var ip = "${ip}";
|
||||
var hostname = "${hostname}";
|
||||
var url;
|
||||
var fetch = function() {
|
||||
tries++;
|
||||
|
||||
if(ip && tries%3 == 0) {
|
||||
url = "http://" + ip;
|
||||
} else if(hostname && tries%3 == 1) {
|
||||
url = "http://" + hostname;
|
||||
} else if(hostname && tries%3 == 2) {
|
||||
url = "http://" + hostname + ".local";
|
||||
} else {
|
||||
url = "";
|
||||
}
|
||||
if(console) console.log("Trying url " + url)
|
||||
$.ajax({
|
||||
url: '/data.json',
|
||||
timeout: interval,
|
||||
dataType: 'json',
|
||||
url: url + '/is-alive',
|
||||
timeout: 5000
|
||||
}).done(function(json) {
|
||||
window.location.href="/";
|
||||
window.location.href = url ? url : "/";
|
||||
}).fail(function() {
|
||||
setTimeout(fetch, interval);
|
||||
setTimeout(fetch, 1000);
|
||||
});
|
||||
};
|
||||
setTimeout(fetch, interval);
|
||||
setTimeout(fetch, 10000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user