Merge branch 'development02' into asyncWeb02

This commit is contained in:
lumapu 2022-08-30 21:43:20 +02:00
commit b871ed06d2
7 changed files with 36 additions and 14 deletions

View file

@ -1,3 +1,5 @@
![actions/workflows/compile_esp8266.yml](../../actions/workflows/compile_esp8266.yml/badge.svg) ![actions/workflows/compile_development.yml](../../actions/workflows/compile_development.yml/badge.svg)
![Logo](https://github.com/grindylow/ahoy/blob/main/doc/logo1_small.png?raw=true)
# ahoy
@ -9,7 +11,7 @@ Click on the link below you are interested in.
There you will find further explanations on how to proceed. (*Note: It is still under construction!*)
##### Most updated section
- [ESP8266](tools/esp8266/) that includes an web interface ![](../../actions/workflows/compile_esp8266.yml/badge.svg)
- [ESP8266](tools/esp8266/) that includes an web interface
##### will be updated as needed
- [Arduino Nano](tools/nano/NRF24_SendRcv/)

View file

@ -54,16 +54,20 @@ void app::loop(void) {
mWebInst->loop();
if(checkTicker(&mUptimeTicker, mUptimeInterval)) {
if(millis() - mPrevMillis >= 1000) {
mPrevMillis += 1000;
mUptimeSecs++;
if(0 != mTimestamp)
mTimestamp++;
else {
}
}
if(checkTicker(&mNtpRefreshTicker, mNtpRefreshInterval)) {
if(!apActive) {
mTimestamp = mWifi->getNtpTime();
DPRINTLN(DBG_INFO, "[NTP]: " + getDateTimeStr(mTimestamp));
}
}
}
if(mShouldReboot) {
DPRINTLN(DBG_INFO, F("Rebooting..."));
@ -661,7 +665,11 @@ const char* app::getFieldStateClass(uint8_t fieldId) {
void app::resetSystem(void) {
mUptimeSecs = 0;
mUptimeTicker = 0xffffffff;
mUptimeInterval = 1000;
mUptimeInterval = 500; // [ms]
mPrevMillis = 0;
mNtpRefreshTicker = 0;
mNtpRefreshInterval = NTP_REFRESH_INTERVAL; // [ms]
#ifdef AP_ONLY
mTimestamp = 1;

View file

@ -217,7 +217,10 @@ class app {
uint32_t mUptimeTicker;
uint16_t mUptimeInterval;
uint32_t mUptimeSecs;
uint32_t mPrevMillis;
uint8_t mHeapStatCnt;
uint32_t mNtpRefreshTicker;
uint32_t mNtpRefreshInterval;
bool mWifiSettingsValid;

View file

@ -72,12 +72,15 @@
// threshold of minimum power on which the inverter is marked as inactive
#define INACT_PWR_THRESH 3
// default ntp server uri
// default NTP server uri
#define DEF_NTP_SERVER_NAME "pool.ntp.org"
// default ntp server port
// default NTP server port
#define DEF_NTP_PORT 8888
// NTP refresh interval in ms (default 12h)
#define NTP_REFRESH_INTERVAL 12 * 3600 * 1000
// default mqtt interval
#define MQTT_INTERVAL 60

View file

@ -2,6 +2,8 @@ import re
import os
import gzip
from pathlib import Path
def convert2Header(inFile, compress):
fileType = inFile.split(".")[1]
define = inFile.split(".")[0].upper()
@ -12,8 +14,10 @@ def convert2Header(inFile, compress):
if os.getcwd()[-4:] != "html":
outName = "html/" + "h/" + inFileVarName + ".h"
inFile = "html/" + inFile
Path("html/h").mkdir(exist_ok=True)
else:
outName = "h/" + inFileVarName + ".h"
Path("h").mkdir(exist_ok=True)
f = open(inFile, "r")
data = f.read()

View file

@ -61,7 +61,7 @@
<fieldset>
<legend class="des">MQTT</legend>
<label for="mqttAddr">Broker / Server IP</label>
<input type="text" class="text" name="mqttAddr"/>
<input type="text" class="text" name="mqttAddr" maxlength="32" />
<label for="mqttPort">Port</label>
<input type="text" class="text" name="mqttPort"/>
<label for="mqttUser">Username (optional)</label>

View file

@ -288,7 +288,9 @@ void web::showSave(AsyncWebServerRequest *request) {
// mqtt
if(request->arg("mqttAddr") != "") {
request->arg("mqttAddr").toCharArray(mConfig->mqtt.broker, MQTT_ADDR_LEN);
String addr = mWeb->arg("mqttAddr");
addr.trim();
addr.toCharArray(mConfig->mqtt.broker, MQTT_ADDR_LEN);
request->arg("mqttUser").toCharArray(mConfig->mqtt.user, MQTT_USER_LEN);
if(request->arg("mqttPwd") != "{PWD}")
request->arg("mqttPwd").toCharArray(mConfig->mqtt.pwd, MQTT_PWD_LEN);