Browse Source

Add disclaimer to the Ahoy

pull/357/head
DanielR92 2 years ago
parent
commit
86b3137b6a
  1. 3
      tools/esp8266/app.cpp
  2. 6
      tools/esp8266/defines.h
  3. 18
      tools/esp8266/html/index.html
  4. 4
      tools/esp8266/html/setup.html
  5. 5
      tools/esp8266/web.cpp
  6. 1
      tools/esp8266/webApi.cpp

3
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;
}

6
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

18
tools/esp8266/html/index.html

@ -9,6 +9,21 @@
<body>
<h1>AHOY</h1>
<div id="content" class="content">
<SCRIPT>
function promptFunction() {
var Text = prompt("This project was started from https://www.mikrocontroller.net/topic/525778 this discussion.\n\n" +
"The Hoymiles protocol was decrypted through the voluntary efforts of many participants. ahoy, among others, was developed based on this work. The project is licensed under an Open Source " +
"License (https://github.com/lumapu/ahoy/blob/main/LICENSE) GNU General Public License v3.0.\n\n" +
"The software was developed to the best of our knowledge and belief. Nevertheless, no liability can be accepted for a malfunction or guarantee loss of the inverter.\n\n" +
"Ahoy is freely available. If you paid money for the software, you probably got ripped off.\n\nPlease type in 'YeS', you are accept our Disclaim.", "");
if (Text != "YeS")
promptFunction();
else
return true;
}
</SCRIPT>
<p>
<a href="/live">Visualization</a><br/>
<br/>
@ -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"];

4
tools/esp8266/html/setup.html

@ -28,6 +28,7 @@
<legend class="des">Device Host Name</legend>
<label for="device">Device Name</label>
<input type="text" name="device" class="text"/>
<input type="hidden" name="disclaimer" value="false" id="disclaimer">
</fieldset>
<button type="button" class="s_collapsible">WiFi</button>
@ -325,6 +326,9 @@
parseSerial(root["serial"]);
}
}
hiddenInput = document.getElementById("disclaimer")
hiddenInput.value = sessionStorage.getItem("gDisclaimer");
getAjax("/api/setup", parse);
</script>

5
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 ++) {

1
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;
}

Loading…
Cancel
Save