Browse Source

channel name can use any character, not limited any more

added `/` to MQTT topic and Inverter name
trigger for `calcSunrise` is now using local time #515
fix reconnect timeout for WiFi #509
start AP only after boot, not on WiFi connection loss
improved /system `free_heap` value (measured before JSON-tree is built)
pull/558/head
lumapu 2 years ago
parent
commit
73b6ff073c
  1. 8
      src/CHANGES.md
  2. 2
      src/app.cpp
  3. 2
      src/app.h
  4. 2
      src/defines.h
  5. 6
      src/web/RestApi.h
  6. 6
      src/web/html/setup.html
  7. 11
      src/wifi/ahoywifi.cpp
  8. 2
      src/wifi/ahoywifi.h

8
src/CHANGES.md

@ -1,5 +1,13 @@
# Changelog
## 0.5.64
* channel name can use any character, not limited any more
* added `/` to MQTT topic and Inverter name
* trigger for `calcSunrise` is now using local time #515
* fix reconnect timeout for WiFi #509
* start AP only after boot, not on WiFi connection loss
* improved /system `free_heap` value (measured before JSON-tree is built)
## 0.5.63
* fix Update button protection (prevent double click #527)
* optimized scheduler #515 (thx @beegee3)

2
src/app.cpp

@ -141,7 +141,7 @@ void app::tickCalcSunrise(void) {
ah::calculateSunriseSunset(mTimestamp, mCalculatedTimezoneOffset, mConfig->sun.lat, mConfig->sun.lon, &mSunrise, &mSunset);
tickIVCommunication();
uint32_t nxtTrig = mTimestamp - ((mTimestamp - 10) % 86400) + 86400; // next midnight, -10 for safety that it is certain next day
uint32_t nxtTrig = mTimestamp - ((mTimestamp + mCalculatedTimezoneOffset - 10) % 86400) + 86400;; // next midnight, -10 for safety that it is certain next day, local timezone
onceAt(std::bind(&app::tickCalcSunrise, this), nxtTrig);
if (mConfig->mqtt.broker[0] > 0) {
mMqtt.tickerSun(mSunrise, mSunset, mConfig->sun.offsetSec, mConfig->sun.disNightCom);

2
src/app.h

@ -156,7 +156,7 @@ class app : public IApp, public ah::Scheduler {
}
void getSchedulerInfo(uint8_t *max) {
return getStat(max);
getStat(max);
}
void setTimestamp(uint32_t newTime) {

2
src/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 5
#define VERSION_PATCH 63
#define VERSION_PATCH 64
//-------------------------------------
typedef struct {

6
src/web/RestApi.h

@ -19,6 +19,7 @@ class RestApi {
public:
RestApi() {
mTimezoneOffset = 0;
mFreeHeap = 0;
}
void setup(IApp *app, HMSYSTEM *sys, AsyncWebServer *srv, settings_t *config) {
@ -51,6 +52,8 @@ class RestApi {
private:
void onApi(AsyncWebServerRequest *request) {
mFreeHeap = ESP.getFreeHeap();
AsyncJsonResponse* response = new AsyncJsonResponse(false, 8192);
JsonObject root = response->getRoot();
@ -168,7 +171,7 @@ class RestApi {
obj[F("sdk")] = ESP.getSdkVersion();
obj[F("cpu_freq")] = ESP.getCpuFreqMHz();
obj[F("heap_free")] = ESP.getFreeHeap();
obj[F("heap_free")] = mFreeHeap;
obj[F("sketch_total")] = ESP.getFreeSketchSpace();
obj[F("sketch_used")] = ESP.getSketchSize() / 1024; // in kb
getGeneric(obj);
@ -571,6 +574,7 @@ class RestApi {
settings_t *mConfig;
uint32_t mTimezoneOffset;
uint32_t mFreeHeap;
};
#endif /*__WEB_API_H__*/

6
src/web/html/setup.html

@ -147,7 +147,7 @@
<label for="mqttPwd">Password (optional)</label>
<input type="password" class="text" name="mqttPwd"/>
<label for="mqttTopic">Topic</label>
<input type="text" class="text" name="mqttTopic" pattern="[A-Za-z0-9.\-_\+]+" title="Invalid input" />
<input type="text" class="text" name="mqttTopic" pattern="[A-Za-z0-9.\-_\+\/]+" title="Invalid input" />
<label for="mqttBtn">Discovery Config (homeassistant)</label>
<input type="button" name="mqttDiscovery" id="mqttDiscovery" class="btn" value="send" onclick="sendDiscoveryConfig()"/>
<span id="apiResultMqtt"></span>
@ -320,10 +320,10 @@
iv.append(
lbl(id + "Name", "Name*"),
inp(id + "Name", obj["name"], 32, ["text"], null, "text", "[A-Za-z0-9.\\-_\\+]+", "Invalid input")
inp(id + "Name", obj["name"], 32, ["text"], null, "text", "[A-Za-z0-9.\\-_\\+\\/]+", "Invalid input")
);
for(var j of [["ModPwr", "ch_max_power", "Max Module Power (Wp)", 4, "[0-9]+"], ["ModName", "ch_name", "Module Name", 16, "[A-Za-z0-9.\\-_\\+]+"]]) {
for(var j of [["ModPwr", "ch_max_power", "Max Module Power (Wp)", 4, "[0-9]+"], ["ModName", "ch_name", "Module Name", 16, null]]) {
var cl = (re.test(obj["serial"])) ? null : ["hide"];
iv.appendChild(lbl(null, j[2], cl, "lbl" + id + j[0]));
d = div([j[0]]);

11
src/wifi/ahoywifi.cpp

@ -35,15 +35,17 @@ void ahoywifi::setup(settings_t *config, uint32_t *utcTimestamp) {
WiFi.onEvent(std::bind(&ahoywifi::onWiFiEvent, this, std::placeholders::_1));
#endif
setupWifi();
setupWifi(true);
}
//-----------------------------------------------------------------------------
void ahoywifi::setupWifi(void) {
void ahoywifi::setupWifi(bool startAP = false) {
#if !defined(FB_WIFI_OVERRIDDEN)
if(startAP) {
setupAp();
delay(1000);
}
#endif
#if !defined(AP_ONLY)
if(mConfig->valid) {
@ -62,7 +64,6 @@ void ahoywifi::setupWifi(void) {
void ahoywifi::tickWifiLoop() {
#if !defined(AP_ONLY)
if(mReconnect) {
delay(100);
if (WiFi.softAPgetStationNum() > 0) { // do not reconnect if any AP connection exists
mDns.processNextRequest();
if((WIFI_AP_STA == WiFi.getMode()) && !mScanActive) {
@ -78,12 +79,10 @@ void ahoywifi::tickWifiLoop() {
}
mCnt++;
if ((mCnt % 10) == 0) {
DBGPRINT(F("reconnect in "));
DBGPRINT(String((100-mCnt)/10));
DBGPRINTLN(F(" seconds"));
}
if((mCnt % 100) == 0) { // try to reconnect after 10 sec without connection
if((mCnt % 10) == 0) { // try to reconnect after 10 sec without connection
WiFi.reconnect();
mCnt = 0;
}

2
src/wifi/ahoywifi.h

@ -27,7 +27,7 @@ class ahoywifi {
void getAvailNetworks(JsonObject obj);
private:
void setupWifi(void);
void setupWifi(bool startAP);
void setupAp(void);
void setupStation(void);
void sendNTPpacket(IPAddress& address);

Loading…
Cancel
Save