Browse Source
Merge pull request #357 from DanielR92/dev03-warning_msg_1
Add disclaimer to the Ahoy
pull/359/head
lumapu
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
36 additions and
1 deletions
tools/esp8266/app.cpp
tools/esp8266/defines.h
tools/esp8266/html/index.html
tools/esp8266/html/setup.html
tools/esp8266/web.cpp
tools/esp8266/webApi.cpp
@ -745,6 +745,9 @@ void app::loadDefaultConfig(void) {
mConfig . serialInterval = SERIAL_INTERVAL ;
mConfig . serialShowIv = false ;
mConfig . serialDebug = false ;
// Disclaimer
mConfig . disclaimer = false ;
}
@ -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
@ -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"];
@ -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 >
@ -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 + + ) {
@ -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 ;
}