From df1e1c2418e381c900f0d72fc0357abf06945582 Mon Sep 17 00:00:00 2001 From: tastendruecker123 <111116980+tastendruecker123@users.noreply.github.com> Date: Tue, 4 Apr 2023 17:06:56 +0200 Subject: [PATCH 1/5] Fixed issue #828. Browser caching, versioned URLs. --- src/web/html/includes/header.html | 6 +++--- src/web/html/includes/nav.html | 14 +++++++------- src/web/web.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/web/html/includes/header.html b/src/web/html/includes/header.html index f38a30f7..d591eb42 100644 --- a/src/web/html/includes/header.html +++ b/src/web/html/includes/header.html @@ -1,5 +1,5 @@ - - + - + + \ No newline at end of file diff --git a/src/web/html/includes/nav.html b/src/web/html/includes/nav.html index 3dac1590..9d6b822c 100644 --- a/src/web/html/includes/nav.html +++ b/src/web/html/includes/nav.html @@ -1,21 +1,21 @@
- AhoyDTU + AhoyDTU
- Live - Serial / Control - Settings + Live + Serial / Control + Settings - Update - System + Update + System REST API Documentation - About + About Login Logout diff --git a/src/web/web.h b/src/web/web.h index 6b7aaed1..68174c8b 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -255,6 +255,9 @@ class Web { AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), update_html, update_html_len); response->addHeader(F("Content-Encoding"), "gzip"); + if(request->hasParam("v")) { + response->addHeader(F("Cache-Control"), F("max-age=604800")); + } request->send(response); } @@ -309,11 +312,15 @@ class Web { AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), index_html, index_html_len); response->addHeader(F("Content-Encoding"), "gzip"); + if(request->hasParam("v")) { + response->addHeader(F("Cache-Control"), F("max-age=604800")); + } request->send(response); } void onLogin(AsyncWebServerRequest *request) { DPRINTLN(DBG_VERBOSE, F("onLogin")); + DPRINTLN(DBG_WARN, String(mConfig->sys.adminPwd)); if (request->args() > 0) { if (String(request->arg("pwd")) == String(mConfig->sys.adminPwd)) { @@ -348,6 +355,9 @@ class Web { else response = request->beginResponse_P(200, F("text/css"), colorBright_css, colorBright_css_len); response->addHeader(F("Content-Encoding"), "gzip"); + if(request->hasParam("v")) { + response->addHeader(F("Cache-Control"), F("max-age=604800")); + } request->send(response); } @@ -356,6 +366,9 @@ class Web { mLogoutTimeout = LOGOUT_TIMEOUT; AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/css"), style_css, style_css_len); response->addHeader(F("Content-Encoding"), "gzip"); + if(request->hasParam("v")) { + response->addHeader(F("Cache-Control"), F("max-age=604800")); + } request->send(response); } @@ -364,6 +377,9 @@ class Web { AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/javascript"), api_js, api_js_len); response->addHeader(F("Content-Encoding"), "gzip"); + if(request->hasParam("v")) { + response->addHeader(F("Cache-Control"), F("max-age=604800")); + } request->send(response); } @@ -429,6 +445,9 @@ class Web { AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), setup_html, setup_html_len); response->addHeader(F("Content-Encoding"), "gzip"); + if(request->hasParam("v")) { + response->addHeader(F("Cache-Control"), F("max-age=604800")); + } request->send(response); } @@ -604,6 +623,9 @@ class Web { AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), visualization_html, visualization_html_len); response->addHeader(F("Content-Encoding"), "gzip"); response->addHeader(F("content-type"), "text/html; charset=UTF-8"); + if(request->hasParam("v")) { + response->addHeader(F("Cache-Control"), F("max-age=604800")); + } request->send(response); } @@ -612,6 +634,9 @@ class Web { AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), about_html, about_html_len); response->addHeader(F("Content-Encoding"), "gzip"); response->addHeader(F("content-type"), "text/html; charset=UTF-8"); + if(request->hasParam("v")) { + response->addHeader(F("Cache-Control"), F("max-age=604800")); + } request->send(response); } @@ -630,6 +655,9 @@ class Web { AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), serial_html, serial_html_len); response->addHeader(F("Content-Encoding"), "gzip"); + if(request->hasParam("v")) { + response->addHeader(F("Cache-Control"), F("max-age=604800")); + } request->send(response); } @@ -641,6 +669,9 @@ class Web { AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); response->addHeader(F("Content-Encoding"), "gzip"); + if(request->hasParam("v")) { + response->addHeader(F("Cache-Control"), F("max-age=604800")); + } request->send(response); } From e8aa1ba11b193391baff95987ce71a1271d306f8 Mon Sep 17 00:00:00 2001 From: tastendruecker123 <111116980+tastendruecker123@users.noreply.github.com> Date: Tue, 4 Apr 2023 17:13:46 +0200 Subject: [PATCH 2/5] removed debugging statement --- src/web/web.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/web/web.h b/src/web/web.h index 68174c8b..32424104 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -320,7 +320,6 @@ class Web { void onLogin(AsyncWebServerRequest *request) { DPRINTLN(DBG_VERBOSE, F("onLogin")); - DPRINTLN(DBG_WARN, String(mConfig->sys.adminPwd)); if (request->args() > 0) { if (String(request->arg("pwd")) == String(mConfig->sys.adminPwd)) { From c7060e40ff2d18a0387956c212a72b5ade5aa98a Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 4 Apr 2023 22:50:21 +0200 Subject: [PATCH 3/5] 0.6.3 * fix login, password length was not checked #852 --- src/CHANGES.md | 3 +++ src/defines.h | 2 +- src/web/web.h | 12 +++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 3702d0e6..7af7279e 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.6.3 - 2023-04-04 +* fix login, password length was not checked #852 + ## 0.6.2 - 2023-04-04 * fix login from multiple clients #819 * fix login screen on small displays diff --git a/src/defines.h b/src/defines.h index 5d01003b..13799dbc 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 6 -#define VERSION_PATCH 2 +#define VERSION_PATCH 3 //------------------------------------- typedef struct { diff --git a/src/web/web.h b/src/web/web.h index 6b7aaed1..0cafacf6 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -130,11 +130,13 @@ class Web { bool prot; prot = mProtected; if(!prot) { - uint8_t ip[4]; - ah::ip2Arr(ip, request->client()->remoteIP().toString().c_str()); - for(uint8_t i = 0; i < 4; i++) { - if(mLoginIp[i] != ip[i]) - prot = true; + if(strlen(mConfig->sys.adminPwd) > 0) { + uint8_t ip[4]; + ah::ip2Arr(ip, request->client()->remoteIP().toString().c_str()); + for(uint8_t i = 0; i < 4; i++) { + if(mLoginIp[i] != ip[i]) + prot = true; + } } } From 863254aecbe0c93f76630865ffd7733dad3d0966 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 4 Apr 2023 23:12:45 +0200 Subject: [PATCH 4/5] 0.6.3 * merge PR #854 optimize browser caching, thx @tastendruecker123 --- src/CHANGES.md | 1 + src/web/web.h | 81 ++++++++++---------------------------------------- 2 files changed, 16 insertions(+), 66 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 7af7279e..9ab4722e 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,7 @@ ## 0.6.3 - 2023-04-04 * fix login, password length was not checked #852 +* merge PR #854 optimize browser caching, thx @tastendruecker123 ## 0.6.2 - 2023-04-04 * fix login from multiple clients #819 diff --git a/src/web/web.h b/src/web/web.h index 4f816b38..f8abc0f7 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -249,20 +249,22 @@ class Web { } } - void onUpdate(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onUpdate")); - - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_UPDATE)) + void getPage(AsyncWebServerRequest *request, uint8_t mask, const uint8_t *zippedHtml, uint32_t len) { + if (CHECK_MASK(mConfig->sys.protectionMask, mask)) checkProtection(request); - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), update_html, update_html_len); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), zippedHtml, len); response->addHeader(F("Content-Encoding"), "gzip"); - if(request->hasParam("v")) { + response->addHeader(F("content-type"), "text/html; charset=UTF-8"); + if(request->hasParam("v")) response->addHeader(F("Cache-Control"), F("max-age=604800")); - } request->send(response); } + void onUpdate(AsyncWebServerRequest *request) { + getPage(request, PROT_MASK_UPDATE, update_html, update_html_len); + } + void showUpdate(AsyncWebServerRequest *request) { bool reboot = (!Update.hasError()); @@ -307,17 +309,7 @@ class Web { } void onIndex(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onIndex")); - - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_INDEX)) - checkProtection(request); - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), index_html, index_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - if(request->hasParam("v")) { - response->addHeader(F("Cache-Control"), F("max-age=604800")); - } - request->send(response); + getPage(request, PROT_MASK_INDEX, index_html, index_html_len); } void onLogin(AsyncWebServerRequest *request) { @@ -378,9 +370,8 @@ class Web { AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/javascript"), api_js, api_js_len); response->addHeader(F("Content-Encoding"), "gzip"); - if(request->hasParam("v")) { + if(request->hasParam("v")) response->addHeader(F("Cache-Control"), F("max-age=604800")); - } request->send(response); } @@ -439,17 +430,7 @@ class Web { } void onSetup(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onSetup")); - - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SETUP)) - checkProtection(request); - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), setup_html, setup_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - if(request->hasParam("v")) { - response->addHeader(F("Cache-Control"), F("max-age=604800")); - } - request->send(response); + getPage(request, PROT_MASK_SETUP, setup_html, setup_html_len); } void showSave(AsyncWebServerRequest *request) { @@ -616,19 +597,7 @@ class Web { } void onLive(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onLive")); - - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_LIVE)) - checkProtection(request); - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), visualization_html, visualization_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - response->addHeader(F("content-type"), "text/html; charset=UTF-8"); - if(request->hasParam("v")) { - response->addHeader(F("Cache-Control"), F("max-age=604800")); - } - - request->send(response); + getPage(request, PROT_MASK_LIVE, visualization_html, visualization_html_len); } void onAbout(AsyncWebServerRequest *request) { @@ -649,31 +618,11 @@ class Web { } void onSerial(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onSerial")); - - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SERIAL)) - checkProtection(request); - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), serial_html, serial_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - if(request->hasParam("v")) { - response->addHeader(F("Cache-Control"), F("max-age=604800")); - } - request->send(response); + getPage(request, PROT_MASK_SERIAL, serial_html, serial_html_len); } void onSystem(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onSystem")); - - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SYSTEM)) - checkProtection(request); - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - if(request->hasParam("v")) { - response->addHeader(F("Cache-Control"), F("max-age=604800")); - } - request->send(response); + getPage(request, PROT_MASK_SYSTEM, system_html, system_html_len); } From 6e0ab50c1d1c5bce293e1c951c6b2b82f0f00581 Mon Sep 17 00:00:00 2001 From: lumapu Date: Wed, 5 Apr 2023 01:24:37 +0200 Subject: [PATCH 5/5] 0.6.3 * fix WiFi reconnect not working #851 * updated issue templates #822 --- .github/ISSUE_TEMPLATE/report-ahoy.md | 42 +------- .github/ISSUE_TEMPLATE/report.yaml | 132 +++++++------------------- src/CHANGES.md | 4 +- src/wifi/ahoywifi.cpp | 6 +- 4 files changed, 41 insertions(+), 143 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/report-ahoy.md b/.github/ISSUE_TEMPLATE/report-ahoy.md index 1f361271..f7d10494 100644 --- a/.github/ISSUE_TEMPLATE/report-ahoy.md +++ b/.github/ISSUE_TEMPLATE/report-ahoy.md @@ -22,58 +22,22 @@ Retailer URL: ______ ### Antenna: * [ ] circuit board -* [ ] external antenna +* [ ] external antenna (SMA) ### Power Stabilization: * [ ] 100uF Electrolytic Capacitor connected between +3.3V and GND (Pin 1 & 2) of the NRF Module * [ ] Voltage stabilizing motherboard -### Connection diagram: -* [ ] Image of the your wiring attached - -### Connection diagram I used: -| nRF24L01+ Pin | ESP8266 GPIO | -| ------------- | -------------- | -| Pin 1 GND [*] | GND | -| Pin 2 +3.3V | +3.3V | -| Pin 3 CE | GPIO2 CE D4 | -| Pin 4 CSN | GPIO15 CS D8 | -| Pin 5 SCK | GPIO14 SCLK D5 | -| Pin 6 MOSI | GPIO13 MOSI D7 | -| Pin 7 MISO | GPIO12 MISO D6 | -| Pin 8 IRQ | GPIO0 IRQ D3 | - -| nRF24L01+ Pin | ESP32 GPIO | -| ------------- | --------------- | -| Pin 1 GND [*] | GND | -| Pin 2 +3.3V | +3.3V | -| Pin 3 CE | GPIO4 CE D4 | -| Pin 4 CSN | GPIO5 CS D5 | -| Pin 5 SCK | GPIO18 SCLK D18 | -| Pin 6 MOSI | GPIO23 MOSI D23 | -| Pin 7 MISO | GPIO19 MISO D19 | -| Pin 8 IRQ | GPIO0 IRQ D0 | - -Note: [*] GND Pin 1 has a square mark on the nRF24L01+ module - -## Software -* [ ] AhoyDTU -* [ ] OpenDTU - ### Version / Git SHA: Version: _._.__ Github Hash: _______ ### Build & Flash Method: +* [ ] AhoyDTU Webinstaller +* [ ] VSCode - Platform IO * [ ] Arduino * [ ] ESP Tools -* [ ] Platform IO - -### Desktop OS: -* [ ] Linux -* [ ] Windows -* [ ] Mac OS ### Debugging: * [ ] USB Serial Log (attached) diff --git a/.github/ISSUE_TEMPLATE/report.yaml b/.github/ISSUE_TEMPLATE/report.yaml index 6c834480..bab0b3d4 100644 --- a/.github/ISSUE_TEMPLATE/report.yaml +++ b/.github/ISSUE_TEMPLATE/report.yaml @@ -1,18 +1,20 @@ name: "AhoyDTU bug" description: "File a bug report" -title: "[ESP8266/ESP32/RaspberryPi] Problem Description / Beschreibung" +title: "[Bug]" labels: ["bug", "needs-triage"] assignees: - - stefan123t + - lumapu body: - type: markdown attributes: value: | Bitte die Posting Guide lines lesen, Vorlage kopieren und ausfüllen und in Eurem Support Forum Eintrag posten. Wir lesen auch gerne Deutsch, bitte fülle die u.a. Fragen aus damit wir Dir bestmöglich helfen können Danke! + Bitte unser FAQ als Hilfestellung prüfen: https://ahoydtu.de/faq Please read, copy & fill in the template from our Posting Guide lines into your Support Forum post. We do enjoy the english language, but we need a couple of things to best support you in your goal, please fill in all / most of the details given below. Thanks! + Check our FAQ: https://ahoydtu.de/faq - type: markdown attributes: value: "## Hardware" @@ -35,11 +37,21 @@ body: placeholder: validations: required: false + - type: dropdown + id: assembly-type + attributes: + label: Assembly + description: + options: + - I did the assebly by myself + - the DTU was already assembled + validations: + required: true - type: dropdown id: nrf24l01-module attributes: label: nRF24L01+ Module - description: | + description: | What type of nRF24L01+ chip is on your nRF24L01+ module ? * you verified this is a **nRF24L01+ plus** model capable of the required 256kBit/s mode ? * **square dot** indicates original Nordic Semicon chip ? @@ -69,43 +81,11 @@ body: * special **voltage stabilizing board** * **nothing** (yet) options: - - ~100uF Elko + - Elko (~100uF) - board - nothing validations: required: true - - type: textarea - id: connection-diagram - attributes: - label: Connection diagram - description: Tell us which connection diagram you used? - value: | - ## Connection diagram I used: - | nRF24L01+ Pin | ESP8266 GPIO | - | ------------- | -------------- | - | Pin 1 GND [*] | GND | - | Pin 2 +3.3V | +3.3V | - | Pin 3 CE | GPIO2 CE D4 | - | Pin 4 CSN | GPIO15 CS D8 | - | Pin 5 SCK | GPIO14 SCLK D5 | - | Pin 6 MOSI | GPIO13 MOSI D7 | - | Pin 7 MISO | GPIO12 MISO D6 | - | Pin 8 IRQ | GPIO0 IRQ D3 | - - | nRF24L01+ Pin | ESP32 GPIO | - | ------------- | --------------- | - | Pin 1 GND [*] | GND | - | Pin 2 +3.3V | +3.3V | - | Pin 3 CE | GPIO4 CE D4 | - | Pin 4 CSN | GPIO5 CS D5 | - | Pin 5 SCK | GPIO18 SCLK D18 | - | Pin 6 MOSI | GPIO23 MOSI D23 | - | Pin 7 MISO | GPIO19 MISO D19 | - | Pin 8 IRQ | GPIO0 IRQ D0 | - - Note: [*] GND Pin 1 has a square mark on the nRF24L01+ module - validations: - required: true - type: checkboxes id: connection-picture attributes: @@ -123,7 +103,7 @@ body: attributes: label: Version description: What version of our software are you running ? - placeholder: 0.5.17 + placeholder: 0.6.0 validations: required: true - type: input @@ -131,7 +111,7 @@ body: attributes: label: Github Hash description: Which GitHub hash has the build of our software ? - placeholder: 5402e9b + placeholder: 0000000 validations: required: true - type: dropdown @@ -140,19 +120,11 @@ body: label: Build & Flash Method description: What software do you use to flash / build & flash our firmware images ? options: + - AhoyDTU Webinstaller + - VSCode - Platform IO (build & flash) - ESP Tools (flash) - - Platform IO (build & flash) - validations: - required: true - - type: dropdown - id: desktop-os - attributes: - label: Desktop - description: Which operating system are you using on your desktop to build & flash ? - options: - - Linux - - Mac OS - - Windows + - Arduino IDE + - was already installed validations: required: true - type: textarea @@ -160,49 +132,12 @@ body: attributes: label: Setup description: | - Which settings are configured under http://ahoy-dtu/setup ? - Document any relevant setup values correctly. - Copy and paste the Inverter Section if you have multiple Inverters. - value: | - ### Device Host Name - - Device Name: AHOY-DTU - ### WiFi - - SSID: YOUR_WIFI_SSID *don't paste here* - - Password: YOUR_WIFI_PWD *don't paste here* - ### Inverter - #### Inverter 0 - - Address: 1141752123456 - - Name: HM-600 - - Active Power Limit: 65535 - - Active Power Limit Control Type: no powerlimit - - Max Module Power (Wp): 375, 375 - - Module Name: link, rech - ### General - - Interval [s]: 30 - - Max retries per Payload: 5 - ### NTP Server - - NTP Server / IP: pool.ntp.org - - NTP Port: 123 - ### MQTT - - Broker / Server IP: - - Port: 1883 - - Username (optional): - - Password (optional): - - Topic: inverter - ### System Config - #### Pinout (Wemos) - - CS: D8 (GPIO15) - - CE: D4 (GPIO2) - - IRQ: D3 (GPIO0) - #### Radio (NRF24L01+) - - Amplifier Power Level: LOW - #### Serial Console - - print inverter data: [x] - - Serial Debug: [x] - - Interval [s]: 5 - - - Reboot device after successful save: [x] - - SAVE + Which settings were modified to which values? Check this page on your DTU: http://ahoy-dtu/setup + Do not post private data here (SSID / passwords / serial numbers)! + placeholder: | + Some examples: + - MqTT: only broker was added + - Inverter: set intervall to 5 seconds .. validations: required: true - type: textarea @@ -219,12 +154,9 @@ body: attributes: label: Error description description: Please describe what you expected and what happened instead. - value: | - 1) Go to http://ahoy-dtu/setup - 2) configure above settings - 3) Reboot - 4) I did this - 5) I expected that - 6) and something completely differen happened + placeholder: | + 1) I went to https://ahoy-dtu.de/web_install and installed latest release + 2) I did some configurations, especially ... + ... validations: required: true diff --git a/src/CHANGES.md b/src/CHANGES.md index 9ab4722e..36063f46 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,7 +2,9 @@ ## 0.6.3 - 2023-04-04 * fix login, password length was not checked #852 -* merge PR #854 optimize browser caching, thx @tastendruecker123 +* merge PR #854 optimize browser caching, thx @tastendruecker123 #828 +* fix WiFi reconnect not working #851 +* updated issue templates #822 ## 0.6.2 - 2023-04-04 * fix login from multiple clients #819 diff --git a/src/wifi/ahoywifi.cpp b/src/wifi/ahoywifi.cpp index 9677e7ee..08c19070 100644 --- a/src/wifi/ahoywifi.cpp +++ b/src/wifi/ahoywifi.cpp @@ -25,6 +25,7 @@ void ahoywifi::setup(settings_t *config, uint32_t *utcTimestamp, appWifiCb cb) { mStaConn = DISCONNECTED; mCnt = 0; mScanActive = false; + mScanCnt = 0; #if defined(ESP8266) wifiConnectHandler = WiFi.onStationModeConnected(std::bind(&ahoywifi::onConnect, this, std::placeholders::_1)); @@ -109,7 +110,7 @@ void ahoywifi::tickWifiLoop() { DBGPRINTLN(F(" seconds")); if(mScanActive) { getBSSIDs(); - if(!mScanActive) // scan completed + if((!mScanActive) && (!mBSSIDList.empty())) // scan completed if ((mCnt % timeout) < timeout - 2) mCnt = timeout - 2; } @@ -297,8 +298,7 @@ void ahoywifi::getAvailNetworks(JsonObject obj) { void ahoywifi::getBSSIDs() { int n = WiFi.scanComplete(); if (n < 0) { - mScanCnt++; - if (mScanCnt < 20) + if (++mScanCnt < 20) return; } if(n > 0) {