diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 3d7e8b11..fd9866bd 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -745,6 +745,9 @@ void app::loadDefaultConfig(void) { mConfig.serialInterval = SERIAL_INTERVAL; mConfig.serialShowIv = false; mConfig.serialDebug = false; + + // Disclaimer + mConfig.disclaimer = false; } diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 7e6f1b77..47d92444 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -75,6 +75,7 @@ typedef enum { #define PWD_LEN 64 #define DEVNAME_LEN 16 #define CRC_LEN 2 // uint16_t +#define DISCLAIMER 1 #define INV_ADDR_LEN MAX_NUM_INVERTERS * 8 // uint64_t #define INV_NAME_LEN MAX_NUM_INVERTERS * MAX_NAME_LENGTH // char[] @@ -125,6 +126,9 @@ typedef struct { uint8_t pinIrq; uint8_t amplifierPower; + // Disclaimer + bool disclaimer; + // ntp char ntpAddr[NTP_ADDR_LEN]; uint16_t ntpPort; @@ -149,7 +153,7 @@ typedef struct { #define CFG_MQTT_LEN MQTT_ADDR_LEN + 2 + MQTT_USER_LEN + MQTT_PWD_LEN +MQTT_TOPIC_LEN #define CFG_SYS_LEN DEVNAME_LEN + SSID_LEN + PWD_LEN + 1 -#define CFG_LEN 7 + NTP_ADDR_LEN + 2 + CFG_MQTT_LEN + 4 +#define CFG_LEN 7 + NTP_ADDR_LEN + 2 + CFG_MQTT_LEN + 4 + DISCLAIMER #define ADDR_START 0 #define ADDR_CFG_SYS ADDR_START diff --git a/tools/esp8266/html/index.html b/tools/esp8266/html/index.html index 01185a14..9959529f 100644 --- a/tools/esp8266/html/index.html +++ b/tools/esp8266/html/index.html @@ -9,6 +9,21 @@

AHOY

+ +

Visualization

@@ -68,6 +83,9 @@ } function parseSys(obj) { + // Disclaimer + if(obj["disclaimer"] == false) sessionStorage.setItem("gDisclaimer", promptFunction()); + document.getElementById("version").innerHTML = "Git SHA: " + obj["build"] + " :: " + obj["version"]; document.getElementById("wifi_rssi").innerHTML = obj["wifi_rssi"]; diff --git a/tools/esp8266/html/setup.html b/tools/esp8266/html/setup.html index 2021a11f..1715d2bb 100644 --- a/tools/esp8266/html/setup.html +++ b/tools/esp8266/html/setup.html @@ -28,6 +28,7 @@ Device Host Name + @@ -325,6 +326,9 @@ parseSerial(root["serial"]); } } + + hiddenInput = document.getElementById("disclaimer") + hiddenInput.value = sessionStorage.getItem("gDisclaimer"); getAjax("/api/setup", parse); diff --git a/tools/esp8266/web.cpp b/tools/esp8266/web.cpp index 5891fbe1..40e6b4b5 100644 --- a/tools/esp8266/web.cpp +++ b/tools/esp8266/web.cpp @@ -258,6 +258,11 @@ void web::showSave(AsyncWebServerRequest *request) { if(request->arg("invRetry") != "") mConfig->maxRetransPerPyld = request->arg("invRetry").toInt(); + // Disclaimer + if(request->arg("disclaimer") != "") + mConfig->disclaimer = strcmp("true", request->arg("disclaimer").c_str()) == 0 ? true : false; + DPRINTLN(DBG_INFO, request->arg("disclaimer").c_str()); + // pinout uint8_t pin; for(uint8_t i = 0; i < 3; i ++) { diff --git a/tools/esp8266/webApi.cpp b/tools/esp8266/webApi.cpp index 020eaf37..d2a8390a 100644 --- a/tools/esp8266/webApi.cpp +++ b/tools/esp8266/webApi.cpp @@ -143,6 +143,7 @@ void webApi::getSystem(JsonObject obj) { obj[F("ts_uptime")] = mApp->getUptime(); obj[F("ts_now")] = mApp->getTimestamp(); obj[F("wifi_rssi")] = WiFi.RSSI(); + obj[F("disclaimer")] = mConfig->disclaimer; }