mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-10 07:26:38 +02:00
* fix #195: used trim() to remove leading and trailing spaces, added maxlength attr to input field
* started to work on #209: added another timer for NTP update after configurable interval (default 12h)
This commit is contained in:
parent
4796555fac
commit
2bfb6467e0
9 changed files with 22 additions and 21 deletions
|
@ -64,6 +64,13 @@ void app::loop(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(checkTicker(&mNtpRefreshTicker, mNtpRefreshInterval)) {
|
||||||
|
if(!apActive) {
|
||||||
|
mTimestamp = mWifi->getNtpTime();
|
||||||
|
DPRINTLN(DBG_INFO, "[NTP]: " + getDateTimeStr(mTimestamp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mSys->Radio.loop();
|
mSys->Radio.loop();
|
||||||
|
|
||||||
|
@ -655,7 +662,10 @@ const char* app::getFieldStateClass(uint8_t fieldId) {
|
||||||
void app::resetSystem(void) {
|
void app::resetSystem(void) {
|
||||||
mUptimeSecs = 0;
|
mUptimeSecs = 0;
|
||||||
mUptimeTicker = 0xffffffff;
|
mUptimeTicker = 0xffffffff;
|
||||||
mUptimeInterval = 1000;
|
mUptimeInterval = 1000; // [ms]
|
||||||
|
|
||||||
|
mNtpRefreshTicker = 0xffffffff;
|
||||||
|
mNtpRefreshInterval = NTP_REFRESH_INTERVAL; // [ms]
|
||||||
|
|
||||||
#ifdef AP_ONLY
|
#ifdef AP_ONLY
|
||||||
mTimestamp = 1;
|
mTimestamp = 1;
|
||||||
|
|
|
@ -225,6 +225,8 @@ class app {
|
||||||
uint16_t mUptimeInterval;
|
uint16_t mUptimeInterval;
|
||||||
uint32_t mUptimeSecs;
|
uint32_t mUptimeSecs;
|
||||||
uint8_t mHeapStatCnt;
|
uint8_t mHeapStatCnt;
|
||||||
|
uint32_t mNtpRefreshTicker;
|
||||||
|
uint32_t mNtpRefreshInterval;
|
||||||
|
|
||||||
|
|
||||||
bool mWifiSettingsValid;
|
bool mWifiSettingsValid;
|
||||||
|
|
|
@ -72,12 +72,15 @@
|
||||||
// threshold of minimum power on which the inverter is marked as inactive
|
// threshold of minimum power on which the inverter is marked as inactive
|
||||||
#define INACT_PWR_THRESH 3
|
#define INACT_PWR_THRESH 3
|
||||||
|
|
||||||
// default ntp server uri
|
// default NTP server uri
|
||||||
#define DEF_NTP_SERVER_NAME "pool.ntp.org"
|
#define DEF_NTP_SERVER_NAME "pool.ntp.org"
|
||||||
|
|
||||||
// default ntp server port
|
// default NTP server port
|
||||||
#define DEF_NTP_PORT 8888
|
#define DEF_NTP_PORT 8888
|
||||||
|
|
||||||
|
// NTP refresh interval in ms (default 12h)
|
||||||
|
#define NTP_REFRESH_INTERVAL 12 * 3600 * 1000
|
||||||
|
|
||||||
// default mqtt interval
|
// default mqtt interval
|
||||||
#define MQTT_INTERVAL 60
|
#define MQTT_INTERVAL 60
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef __INDEX_HTML_H__
|
|
||||||
#define __INDEX_HTML_H__
|
|
||||||
const char index_html[] PROGMEM = "<!doctype html><html><head><title>Index - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script type=\"text/javascript\">getAjax('/uptime', 'uptime');getAjax('/cmdstat', 'cmds');window.setInterval(\"getAjax('/uptime', 'uptime')\", {JS_TS});window.setInterval(\"getAjax('/cmdstat', 'cmds')\", {JS_TS});function getAjax(url, resid) {var http = null;http = new XMLHttpRequest();if(http != null) {http.open(\"GET\", url, true);http.onreadystatechange = print;http.send(null);}function print() {if(http.readyState == 4) {document.getElementById(resid).innerHTML = http.responseText;}}}function getInverterInfo(data){var http = null;http = new XMLHttpRequest();if(http != null) {http.open(\"POST\", \"/api\");http.setRequestHeader(\"Accept\", \"application/json\");http.setRequestHeader(\"Content-Type\", \"application/json\");http.send(data);}}</script></head><body><h1>AHOY - {DEVICE}</h1><div id=\"content\" class=\"content\"><p><a href=\"/visualization\">Visualization</a><br/><br/><a href=\"/setup\">Setup</a><br/></p><p><span class=\"des\">Uptime: </span><span id=\"uptime\"></span></p><p><span class=\"des\">Statistics: </span><pre id=\"cmds\"></pre></p><p>Every {TS}seconds the values are updated</p><div id=\"note\">This project was started from <a href=\"https://www.mikrocontroller.net/topic/525778\" target=\"_blank\">this discussion. (Mikrocontroller.net)</a><br/>New updates can be found on Github: <a href=\"https://github.com/grindylow/ahoy\" target=\"_blank\">https://github.com/grindylow/ahoy</a><br/><br/>Please report issues using the feature provided by <a href=\"https://github.com/grindylow/ahoy/issues\">Github</a><br/><br/>Discuss with us on <a href=\"https://discord.gg/WzhxEY62mB\">Discord</a><br/><p class=\"lic\"><a href=\"https://creativecommons.org/licenses/by-nc-sa/3.0/de\">Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/</a><br/>Check the licenses which are published on <a href=\"https://github.com/grindylow/ahoy\">https://github.com/grindylow/ahoy</a>as well</p></div></div><div id=\"footer\"><p class=\"left\">© 2022</p><p class=\"left\"><a href=\"/update\">Update Firmware</a></p><p class=\"right\">AHOY :: {VERSION}</p><p class=\"right\"><a href=\"/reboot\">Reboot</a></p><p class=\"right\">Git SHA: {BUILD}</p></div></body></html>";
|
|
||||||
#endif /*__INDEX_HTML_H__*/
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +0,0 @@
|
||||||
#ifndef __STYLE_CSS_H__
|
|
||||||
#define __STYLE_CSS_H__
|
|
||||||
const char style_css[] PROGMEM = "h1 {margin:0;padding:20pt;font-size:22pt;color:#fff;background-color:#006ec0;display:block;text-transform:uppercase;}html, body {font-family:Arial;margin:0;padding:0;}p {text-align:justify;font-size:13pt;}p.lic, p.lic a {font-size:8pt;color:#999;}.des {margin-top:20px;font-size:13pt;color:#006ec0;}.s_active, .s_collapsible:hover {background-color:#006ec0;}.s_content {display:none;overflow:hidden;}.s_collapsible {background-color:#044e86;color:white;cursor:pointer;padding:18px;width:100%;border:none;text-align:left;outline:none;font-size:15px;margin-bottom:4px;}.subdes {font-size:12pt;color:#006ec0;margin-left:7px;}.subsubdes {font-size:12pt;color:#006ec0;margin:0 0 7px 12px;}.hide {display:none;}a:link, a:visited {text-decoration:none;font-size:13pt;color:#006ec0;}a:hover, a:focus {color:#f00;}a.erase {background-color:#006ec0;color:#fff;padding:7px;display:inline-block;margin-top:30px;}#content {padding:15px 15px 60px 15px;}#footer {position:fixed;bottom:0px;height:45px;background-color:#006ec0;width:100%;border-top:5px solid #fff;}#footer p, #footer a {color:#fff;padding:0 7px 0 7px;font-size:10pt !important;}div.content {background-color:#fff;padding-bottom:65px;overflow:auto;}input, select {padding:7px;font-size:13pt;}input.text, select {width:70%;box-sizing:border-box;margin-bottom:10px;border:1px solid #ccc;}input.sh {max-width:150px !important;margin-right:10px;}input.btn {background-color:#006ec0;color:#fff;border:0px;float:right;margin:10px 0 30px;text-transform:uppercase;}input.cb {margin-bottom:20px;}label {width:20%;display:inline-block;font-size:12pt;padding-right:10px;margin:10px 0px 0px 15px;vertical-align:top;}fieldset {margin-bottom:15px;}.left {float:left;}.right {float:right;}div.ch-iv {width:100%;background-color:#32b004;display:inline-block;margin-bottom:15px;padding-bottom:20px;overflow:auto;}div.ch {width:220px;min-height:350px;background-color:#006ec0;display:inline-block;margin:0 10px 15px 10px;overflow:auto;padding-bottom:20px;}div.ch .value, div.ch .info, div.ch .head, div.ch-iv .value, div.ch-iv .info, div.ch-iv .head {color:#fff;display:block;width:100%;text-align:center;}.subgrp {float:left;width:220px;}div.ch .unit, div.ch-iv .unit {font-size:19px;margin-left:10px;}div.ch .value, div.ch-iv .value {margin-top:20px;font-size:24px;}div.ch .info, div.ch-iv .info {margin-top:3px;font-size:10px;}div.ch .head {background-color:#003c80;padding:10px 0 10px 0;}div.ch-iv .head {background-color:#1c6800;padding:10px 0 10px 0;}div.iv {max-width:960px;margin-bottom:40px;}div.ts {font-size:13px;background-color:#ddd;border-top:7px solid #999;padding:7px;}div.modpwr, div.modname {width:70%;display:inline-block;}#note {margin:50px 10px 10px 10px;padding-top:10px;width:100%;border-top:1px solid #bbb;}@media(max-width:500px) {div.ch .unit, div.ch-iv .unit {font-size:18px;}div.ch {width:170px;min-height:100px }.subgrp {width:180px;}}";
|
|
||||||
#endif /*__STYLE_CSS_H__*/
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef __VISUALIZATION_HTML_H__
|
|
||||||
#define __VISUALIZATION_HTML_H__
|
|
||||||
const char visualization_html[] PROGMEM = "<!doctype html><html><head><title>Index - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script type=\"text/javascript\">getAjax('/livedata', 'livedata');window.setInterval(\"getAjax('/livedata', 'livedata')\", {JS_TS});function getAjax(url, resid) {var http = null;http = new XMLHttpRequest();if(http != null) {http.open(\"GET\", url, true);http.onreadystatechange = print;http.send(null);}function print() {if(http.readyState == 4) {document.getElementById(resid).innerHTML = http.responseText;}}}</script><style type=\"text/css\"></style></head><body><h1>AHOY - {DEVICE}</h1><div id=\"content\" class=\"content\"><div id=\"livedata\"></div><p>Every {TS}seconds the values are updated</p></div><div id=\"footer\"><p class=\"left\">© 2022</p><p class=\"left\"><a href=\"/\">Home</a></p><p class=\"right\">AHOY :: {VERSION}</p></div></body></html>";
|
|
||||||
#endif /*__VISUALIZATION_HTML_H__*/
|
|
|
@ -102,7 +102,7 @@
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend class="des">MQTT</legend>
|
<legend class="des">MQTT</legend>
|
||||||
<label for="mqttAddr">Broker / Server IP</label>
|
<label for="mqttAddr">Broker / Server IP</label>
|
||||||
<input type="text" class="text" name="mqttAddr" value="{MQTT_ADDR}"/>
|
<input type="text" class="text" name="mqttAddr" value="{MQTT_ADDR}" maxlength="32" />
|
||||||
<label for="mqttPort">Port</label>
|
<label for="mqttPort">Port</label>
|
||||||
<input type="text" class="text" name="mqttPort" value="{MQTT_PORT}"/>
|
<input type="text" class="text" name="mqttPort" value="{MQTT_PORT}"/>
|
||||||
<label for="mqttUser">Username (optional)</label>
|
<label for="mqttUser">Username (optional)</label>
|
||||||
|
|
|
@ -384,7 +384,9 @@ void web::showSave(void) {
|
||||||
|
|
||||||
// mqtt
|
// mqtt
|
||||||
if(mWeb->arg("mqttAddr") != "") {
|
if(mWeb->arg("mqttAddr") != "") {
|
||||||
mWeb->arg("mqttAddr").toCharArray(mConfig->mqtt.broker, MQTT_ADDR_LEN);
|
String addr = mWeb->arg("mqttAddr");
|
||||||
|
addr.trim();
|
||||||
|
addr.toCharArray(mConfig->mqtt.broker, MQTT_ADDR_LEN);
|
||||||
mWeb->arg("mqttUser").toCharArray(mConfig->mqtt.user, MQTT_USER_LEN);
|
mWeb->arg("mqttUser").toCharArray(mConfig->mqtt.user, MQTT_USER_LEN);
|
||||||
mWeb->arg("mqttPwd").toCharArray(mConfig->mqtt.pwd, MQTT_PWD_LEN);
|
mWeb->arg("mqttPwd").toCharArray(mConfig->mqtt.pwd, MQTT_PWD_LEN);
|
||||||
mWeb->arg("mqttTopic").toCharArray(mConfig->mqtt.topic, MQTT_TOPIC_LEN);
|
mWeb->arg("mqttTopic").toCharArray(mConfig->mqtt.topic, MQTT_TOPIC_LEN);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue