From 6721c8bbc11258abed2b066dd23f9ff6de496bff Mon Sep 17 00:00:00 2001 From: lumapu Date: Wed, 25 Jan 2023 22:28:10 +0100 Subject: [PATCH 1/3] wifi debug --- src/CHANGES.md | 3 +- src/web/RestApi.h | 1 + src/wifi/ahoywifi.cpp | 121 ++++++++++++++++++++++++++++++++++-------- src/wifi/ahoywifi.h | 6 +-- 4 files changed, 105 insertions(+), 26 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 9405fb15..4d492205 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -5,7 +5,8 @@ ## 0.5.77 * fix wrong filename for automatically created manifest (online installer) #620 * added rotate display feature #619 -* improved Prometheus endpoint #615, thx to fsck-block +* improved Prometheus endpoint #615, thx to @fsck-block +* improved wifi to connect always to strongest RSSI, thx to @beegee3 #611 ## 0.5.76 * reduce MQTT retry interval from maximum speed to one second diff --git a/src/web/RestApi.h b/src/web/RestApi.h index ec4fd61f..3a5ba0b1 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -601,6 +601,7 @@ class RestApi { bool setSetup(JsonObject jsonIn, JsonObject jsonOut) { if(F("scan_wifi") == jsonIn[F("cmd")]) { + DPRINTLN(DBG_INFO, F("rqst scan")); mApp->scanAvailNetworks(); } else if(F("set_time") == jsonIn[F("cmd")]) diff --git a/src/wifi/ahoywifi.cpp b/src/wifi/ahoywifi.cpp index 6f7725eb..6b5c13a5 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; + mLastApClients = 0; #if defined(ESP8266) wifiConnectHandler = WiFi.onStationModeConnected(std::bind(&ahoywifi::onConnect, this, std::placeholders::_1)); @@ -64,21 +65,44 @@ void ahoywifi::tickWifiLoop() { #if !defined(AP_ONLY) if(mStaConn != GOT_IP) { if (WiFi.softAPgetStationNum() > 0) { // do not reconnect if any AP connection exists - mDns.processNextRequest(); - if((WIFI_AP_STA == WiFi.getMode()) && !mScanActive) { - DBGPRINTLN(F("AP client connected")); - welcome(mApIp.toString()); - WiFi.mode(WIFI_AP); - mAppWifiCb(true); + if(WIFI_AP_STA == WiFi.getMode()) { + if(mScanActive && (mLastApClients != WiFi.softAPgetStationNum())) + mScanActive = false; + + if(mLastApClients != WiFi.softAPgetStationNum()) { + mLastApClients = WiFi.softAPgetStationNum(); + WiFi.scanDelete(); + WiFi.mode(WIFI_AP); + //mDns.start(53, "*", mApIp); + mAppWifiCb(true); + DBGPRINTLN(F("AP client connected")); + welcome(mApIp.toString()); + } } + mDns.processNextRequest(); return; } else if(WIFI_AP == WiFi.getMode()) { + mLastApClients = 0; mCnt = 0; + DPRINTLN(DBG_INFO, "DNS stop"); + mDns.stop(); WiFi.mode(WIFI_AP_STA); } mCnt++; + if(!mScanActive && mBSSIDList.empty()) { // start scanning APs with the given SSID + DBGPRINT(F("scanning APs with SSID ")); + DBGPRINTLN(String(mConfig->sys.stationSsid)); + mScanActive = true; + #if defined(ESP8266) + WiFi.scanNetworks(true, false, 0U, (uint8_t *)mConfig->sys.stationSsid); + #else + WiFi.scanNetworks(true, false, false, 300U, 0U, mConfig->sys.stationSsid); + #endif + return; + } + uint8_t timeout = 10; // seconds if (mStaConn == CONNECTED) // connected but no ip @@ -87,10 +111,27 @@ void ahoywifi::tickWifiLoop() { DBGPRINT(F("reconnect in ")); DBGPRINT(String(timeout-mCnt)); DBGPRINTLN(F(" seconds")); + if(mScanActive) { + getBSSIDs(); + if(!mScanActive) // scan completed + if ((mCnt % timeout) < 8) + mCnt = timeout - 2; + } if((mCnt % timeout) == 0) { // try to reconnect after x sec without connection if(mStaConn != CONNECTED) mStaConn = CONNECTING; - WiFi.reconnect(); + if(mBSSIDList.size() > 0) { // get first BSSID in list + DBGPRINT("try to connect to AP with BSSID:"); + uint8_t bssid[6]; + for (int j = 0; j < 6; j++) { + bssid[j] = mBSSIDList.front(); + mBSSIDList.pop_front(); + DBGPRINT(" " + String(bssid[j], HEX)); + } + DBGPRINTLN(""); + WiFi.disconnect(); + WiFi.begin(mConfig->sys.stationSsid, mConfig->sys.stationPwd, 0, &bssid[0]); + } mCnt = 0; } } @@ -135,7 +176,7 @@ void ahoywifi::setupStation(void) { if(!WiFi.config(ip, gateway, mask, dns1, dns2)) DPRINTLN(DBG_ERROR, F("failed to set static IP!")); } - mStaConn = (WiFi.begin(mConfig->sys.stationSsid, mConfig->sys.stationPwd) != WL_CONNECTED) ? DISCONNECTED : CONNECTED; + mBSSIDList.clear(); if(String(mConfig->sys.deviceName) != "") WiFi.hostname(mConfig->sys.deviceName); WiFi.mode(WIFI_AP_STA); @@ -206,40 +247,72 @@ void ahoywifi::sendNTPpacket(IPAddress& address) { mUdp.endPacket(); } +//----------------------------------------------------------------------------- +void ahoywifi::sortRSSI(int *sort, int n) { + for (int i = 0; i < n; i++) + sort[i] = i; + for (int i = 0; i < n; i++) + for (int j = i + 1; j < n; j++) + if (WiFi.RSSI(sort[j]) > WiFi.RSSI(sort[i])) + std::swap(sort[i], sort[j]); +} //----------------------------------------------------------------------------- void ahoywifi::scanAvailNetworks(void) { + DPRINTLN(DBG_INFO, "start scan"); if(-2 == WiFi.scanComplete()) { mScanActive = true; if(WIFI_AP == WiFi.getMode()) WiFi.mode(WIFI_AP_STA); WiFi.scanNetworks(true); } + else + DPRINTLN(DBG_INFO, "complete!"); } - //----------------------------------------------------------------------------- void ahoywifi::getAvailNetworks(JsonObject obj) { JsonArray nets = obj.createNestedArray("networks"); + DPRINTLN(DBG_INFO, "getAvailNetworks"); int n = WiFi.scanComplete(); + if (n < 0) + return; if(n > 0) { int sort[n]; - for (int i = 0; i < n; i++) - sort[i] = i; - for (int i = 0; i < n; i++) - for (int j = i + 1; j < n; j++) - if (WiFi.RSSI(sort[j]) > WiFi.RSSI(sort[i])) - std::swap(sort[i], sort[j]); + sortRSSI(&sort[0], n); for (int i = 0; i < n; ++i) { - nets[i]["ssid"] = WiFi.SSID(sort[i]); - nets[i]["rssi"] = WiFi.RSSI(sort[i]); + DPRINTLN(DBG_INFO, "found network: " + WiFi.SSID(sort[i])); + nets[i]["ssid"] = WiFi.SSID(sort[i]); + nets[i]["rssi"] = WiFi.RSSI(sort[i]); } - mScanActive = false; - WiFi.scanDelete(); } + mScanActive = false; + WiFi.scanDelete(); } +//----------------------------------------------------------------------------- +void ahoywifi::getBSSIDs() { + int n = WiFi.scanComplete(); + if (n < 0) + return; + if(n > 0) { + mBSSIDList.clear(); + int sort[n]; + sortRSSI(&sort[0], n); + for (int i = 0; i < n; i++) { + DBGPRINT("BSSID " + String(i) + ":"); + uint8_t *bssid = WiFi.BSSID(sort[i]); + for (int j = 0; j < 6; j++){ + DBGPRINT(" " + String(bssid[j], HEX)); + mBSSIDList.push_back(bssid[j]); + } + DBGPRINTLN(""); + } + } + mScanActive = false; + WiFi.scanDelete(); +} //----------------------------------------------------------------------------- void ahoywifi::connectionEvent(WiFiStatus_t status) { @@ -248,15 +321,19 @@ void ahoywifi::connectionEvent(WiFiStatus_t status) { if(mStaConn != CONNECTED) { mStaConn = CONNECTED; DBGPRINTLN(F("\n[WiFi] Connected")); - WiFi.mode(WIFI_STA); - DBGPRINTLN(F("[WiFi] AP disabled")); - mDns.stop(); } break; case GOT_IP: mStaConn = GOT_IP; + if (mScanActive) { // maybe another scan has started + WiFi.scanDelete(); + mScanActive = false; + } welcome(WiFi.localIP().toString() + F(" (Station)")); + mDns.stop(); + WiFi.mode(WIFI_STA); + DBGPRINTLN(F("[WiFi] AP disabled")); mAppWifiCb(true); break; diff --git a/src/wifi/ahoywifi.h b/src/wifi/ahoywifi.h index 7155a427..549bf716 100644 --- a/src/wifi/ahoywifi.h +++ b/src/wifi/ahoywifi.h @@ -50,7 +50,8 @@ class ahoywifi { void onWiFiEvent(WiFiEvent_t event); #endif void welcome(String msg); - + void sortRSSI(int *sort, int n); + void getBSSIDs(void); settings_t *mConfig; appWifiCb mAppWifiCb; @@ -68,9 +69,8 @@ class ahoywifi { uint8_t mLoopCnt; bool mScanActive; + uint8_t mLastApClients; - void sortRSSI(int *sort, int n); - void getBSSIDs(void); std::list mBSSIDList; }; From f8d4b4f5ae90d4fc4447eb05cfbe258bd696b398 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 28 Jan 2023 23:37:40 +0100 Subject: [PATCH 2/3] fixed Wifi scan during first configuration (client connected to AP of Ahoy) #611 --- src/web/RestApi.h | 4 +--- src/wifi/ahoywifi.cpp | 26 ++++++++++++++++---------- src/wifi/ahoywifi.h | 1 + 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 3a5ba0b1..43d53500 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -600,10 +600,8 @@ class RestApi { } bool setSetup(JsonObject jsonIn, JsonObject jsonOut) { - if(F("scan_wifi") == jsonIn[F("cmd")]) { - DPRINTLN(DBG_INFO, F("rqst scan")); + if(F("scan_wifi") == jsonIn[F("cmd")]) mApp->scanAvailNetworks(); - } else if(F("set_time") == jsonIn[F("cmd")]) mApp->setTimestamp(jsonIn[F("val")]); else if(F("sync_ntp") == jsonIn[F("cmd")]) diff --git a/src/wifi/ahoywifi.cpp b/src/wifi/ahoywifi.cpp index 6b5c13a5..3fcbe22b 100644 --- a/src/wifi/ahoywifi.cpp +++ b/src/wifi/ahoywifi.cpp @@ -26,6 +26,7 @@ void ahoywifi::setup(settings_t *config, uint32_t *utcTimestamp, appWifiCb cb) { mCnt = 0; mScanActive = false; mLastApClients = 0; + mScanCnt = 0; #if defined(ESP8266) wifiConnectHandler = WiFi.onStationModeConnected(std::bind(&ahoywifi::onConnect, this, std::placeholders::_1)); @@ -66,15 +67,21 @@ void ahoywifi::tickWifiLoop() { if(mStaConn != GOT_IP) { if (WiFi.softAPgetStationNum() > 0) { // do not reconnect if any AP connection exists if(WIFI_AP_STA == WiFi.getMode()) { + // first time switch to AP Mode if(mScanActive && (mLastApClients != WiFi.softAPgetStationNum())) mScanActive = false; + // scan is finished + if(!mScanActive) { + WiFi.mode(WIFI_AP); + mDns.start(53, "*", mApIp); + } + + // only once a client connects to AP if(mLastApClients != WiFi.softAPgetStationNum()) { mLastApClients = WiFi.softAPgetStationNum(); WiFi.scanDelete(); - WiFi.mode(WIFI_AP); - //mDns.start(53, "*", mApIp); - mAppWifiCb(true); + mAppWifiCb(false); DBGPRINTLN(F("AP client connected")); welcome(mApIp.toString()); } @@ -94,6 +101,7 @@ void ahoywifi::tickWifiLoop() { if(!mScanActive && mBSSIDList.empty()) { // start scanning APs with the given SSID DBGPRINT(F("scanning APs with SSID ")); DBGPRINTLN(String(mConfig->sys.stationSsid)); + mScanCnt = 0; mScanActive = true; #if defined(ESP8266) WiFi.scanNetworks(true, false, 0U, (uint8_t *)mConfig->sys.stationSsid); @@ -259,21 +267,17 @@ void ahoywifi::sortRSSI(int *sort, int n) { //----------------------------------------------------------------------------- void ahoywifi::scanAvailNetworks(void) { - DPRINTLN(DBG_INFO, "start scan"); if(-2 == WiFi.scanComplete()) { mScanActive = true; if(WIFI_AP == WiFi.getMode()) WiFi.mode(WIFI_AP_STA); WiFi.scanNetworks(true); } - else - DPRINTLN(DBG_INFO, "complete!"); } //----------------------------------------------------------------------------- void ahoywifi::getAvailNetworks(JsonObject obj) { JsonArray nets = obj.createNestedArray("networks"); - DPRINTLN(DBG_INFO, "getAvailNetworks"); int n = WiFi.scanComplete(); if (n < 0) @@ -282,7 +286,6 @@ void ahoywifi::getAvailNetworks(JsonObject obj) { int sort[n]; sortRSSI(&sort[0], n); for (int i = 0; i < n; ++i) { - DPRINTLN(DBG_INFO, "found network: " + WiFi.SSID(sort[i])); nets[i]["ssid"] = WiFi.SSID(sort[i]); nets[i]["rssi"] = WiFi.RSSI(sort[i]); } @@ -294,8 +297,11 @@ void ahoywifi::getAvailNetworks(JsonObject obj) { //----------------------------------------------------------------------------- void ahoywifi::getBSSIDs() { int n = WiFi.scanComplete(); - if (n < 0) - return; + if (n < 0){ + mScanCnt++; + if (mScanCnt < 20) + return; + } if(n > 0) { mBSSIDList.clear(); int sort[n]; diff --git a/src/wifi/ahoywifi.h b/src/wifi/ahoywifi.h index 549bf716..321dbb86 100644 --- a/src/wifi/ahoywifi.h +++ b/src/wifi/ahoywifi.h @@ -70,6 +70,7 @@ class ahoywifi { uint8_t mLoopCnt; bool mScanActive; uint8_t mLastApClients; + uint8_t mScanCnt; std::list mBSSIDList; }; From 8457f46b0c6d24d41671ff52fb78a95cdc394a45 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 29 Jan 2023 00:55:10 +0100 Subject: [PATCH 3/3] further improvements regarding wifi #611, fix connection if only one AP with same SSID is there fix endless loop in `zerovalues` #564 fix auto discover again #565 added total values to autodiscover #630 improved zero at midnight #625 --- src/CHANGES.md | 7 ++++ src/defines.h | 2 +- src/publisher/pubMqtt.h | 78 ++++++++++++++++++++++++++--------------- src/wifi/ahoywifi.cpp | 19 +++++----- 4 files changed, 66 insertions(+), 40 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 4d492205..9e31ada2 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,13 @@ (starting from release version `0.5.66`) +## 0.5.78 +* further improvements regarding wifi #611, fix connection if only one AP with same SSID is there +* fix endless loop in `zerovalues` #564 +* fix auto discover again #565 +* added total values to autodiscover #630 +* improved zero at midnight #625 + ## 0.5.77 * fix wrong filename for automatically created manifest (online installer) #620 * added rotate display feature #619 diff --git a/src/defines.h b/src/defines.h index ecb161bc..5c626e02 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 77 +#define VERSION_PATCH 78 //------------------------------------- typedef struct { diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index f066a38a..021a29eb 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -133,6 +133,7 @@ class PubMqtt { void tickerMidnight() { Inverter<> *iv; record_t<> *rec; + char topic[7 + MQTT_TOPIC_LEN], val[4]; // set YieldDay to zero for (uint8_t id = 0; id < mSys->getNumInverters(); id++) { @@ -142,10 +143,11 @@ class PubMqtt { rec = iv->getRecordStruct(RealTimeRunData_Debug); uint8_t pos = iv->getPosByChFld(CH0, FLD_YD, rec); iv->setValue(pos, rec, 0.0f); - } - mSendList.push(RealTimeRunData_Debug); - sendIvData(); + snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/ch0/%s", iv->config->name, fields[FLD_YD]); + snprintf(val, 4, "0.0"); + publish(topic, val, true); + } } void payloadEventListener(uint8_t cmd) { @@ -210,7 +212,10 @@ class PubMqtt { DPRINTLN(DBG_VERBOSE, F("sendMqttDiscoveryConfig")); char topic[64], name[32], uniq_id[32]; - DynamicJsonDocument doc(512); + DynamicJsonDocument doc(128); + + uint8_t fldTotal[4] = {FLD_PAC, FLD_YT, FLD_YD, FLD_PDC}; + for (uint8_t id = 0; id < mSys->getNumInverters(); id++) { Inverter<> *iv = mSys->getInverterByPos(id); if (NULL == iv) @@ -218,41 +223,55 @@ class PubMqtt { record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); doc.clear(); + doc[F("name")] = iv->config->name; doc[F("ids")] = String(iv->config->serial.u64, HEX); doc[F("cu")] = F("http://") + String(WiFi.localIP().toString()); doc[F("mf")] = F("Hoymiles"); doc[F("mdl")] = iv->config->name; - JsonObject deviceObj = doc.as(); - - for (uint8_t i = 0; i < rec->length; i++) { - if (rec->assign[i].ch == CH0) - snprintf(name, 32, "%s %s", iv->config->name, iv->getFieldName(i, rec)); - else - snprintf(name, 32, "%s CH%d %s", iv->config->name, rec->assign[i].ch, iv->getFieldName(i, rec)); - snprintf(topic, 64, "/ch%d/%s", rec->assign[i].ch, iv->getFieldName(i, rec)); - snprintf(uniq_id, 32, "ch%d_%s", rec->assign[i].ch, iv->getFieldName(i, rec)); - - const char *devCls = getFieldDeviceClass(rec->assign[i].fieldId); - const char *stateCls = getFieldStateClass(rec->assign[i].fieldId); - - doc.clear(); - doc[F("name")] = name; - doc[F("stat_t")] = String(mCfgMqtt->topic) + "/" + String(iv->config->name) + String(topic); - doc[F("unit_of_meas")] = iv->getUnit(i, rec); - doc[F("uniq_id")] = String(iv->config->serial.u64, HEX) + "_" + uniq_id; - doc[F("dev")] = deviceObj; - doc[F("exp_aft")] = MQTT_INTERVAL + 5; // add 5 sec if connection is bad or ESP too slow @TODO: stimmt das wirklich als expire!? + JsonObject deviceObj = doc.as(); // deviceObj is only pointer!? + + for (uint8_t i = 0; i < (rec->length + 4); i++) { + const char *devCls, *stateCls; + if(i < rec->length) { + if (rec->assign[i].ch == CH0) + snprintf(name, 32, "%s %s", iv->config->name, iv->getFieldName(i, rec)); + else + snprintf(name, 32, "%s CH%d %s", iv->config->name, rec->assign[i].ch, iv->getFieldName(i, rec)); + snprintf(topic, 64, "/ch%d/%s", rec->assign[i].ch, iv->getFieldName(i, rec)); + snprintf(uniq_id, 32, "ch%d_%s", rec->assign[i].ch, iv->getFieldName(i, rec)); + + devCls = getFieldDeviceClass(rec->assign[i].fieldId); + stateCls = getFieldStateClass(rec->assign[i].fieldId); + } + else { // total values + snprintf(name, 32, "Total %s", fields[fldTotal[i-rec->length]]); + snprintf(topic, 64, "/%s", fields[fldTotal[i-rec->length]]); + snprintf(uniq_id, 32, "total_%s", fields[fldTotal[i-rec->length]]); + devCls = getFieldDeviceClass(fldTotal[i-rec->length]); + stateCls = getFieldStateClass(fldTotal[i-rec->length]); + } + + DynamicJsonDocument doc2(512); + doc2[F("name")] = name; + doc2[F("stat_t")] = String(mCfgMqtt->topic) + "/" + String(iv->config->name) + String(topic); + doc2[F("unit_of_meas")] = iv->getUnit(((i < rec->length) ? i : (i - rec->length)), rec); + doc2[F("uniq_id")] = String(iv->config->serial.u64, HEX) + "_" + uniq_id; + doc2[F("dev")] = deviceObj; + doc2[F("exp_aft")] = MQTT_INTERVAL + 5; // add 5 sec if connection is bad or ESP too slow @TODO: stimmt das wirklich als expire!? if (devCls != NULL) - doc[F("dev_cla")] = String(devCls); + doc2[F("dev_cla")] = String(devCls); if (stateCls != NULL) - doc[F("stat_cla")] = String(stateCls); + doc2[F("stat_cla")] = String(stateCls); - snprintf(topic, 64, "%s/sensor/%s/ch%d_%s/config", MQTT_DISCOVERY_PREFIX, iv->config->name, rec->assign[i].ch, iv->getFieldName(i, rec)); - size_t size = measureJson(doc) + 1; + if(i < rec->length) + snprintf(topic, 64, "%s/sensor/%s/ch%d_%s/config", MQTT_DISCOVERY_PREFIX, iv->config->name, rec->assign[i].ch, iv->getFieldName(i, rec)); + else // total values + snprintf(topic, 64, "%s/sensor/%s/total_%s/config", MQTT_DISCOVERY_PREFIX, iv->config->name, fields[fldTotal[i-rec->length]]); + size_t size = measureJson(doc2) + 1; char *buf = new char[size]; memset(buf, 0, size); - serializeJson(doc, buf, size); + serializeJson(doc2, buf, size); publish(topic, buf, true, false); delete[] buf; } @@ -582,6 +601,7 @@ class PubMqtt { case FLD_FW_BUILD_HOUR_MINUTE: case FLD_HW_ID: case FLD_ACT_ACTIVE_PWR_LIMIT: + fld++; continue; break; } diff --git a/src/wifi/ahoywifi.cpp b/src/wifi/ahoywifi.cpp index 3fcbe22b..4ca7f290 100644 --- a/src/wifi/ahoywifi.cpp +++ b/src/wifi/ahoywifi.cpp @@ -98,7 +98,12 @@ void ahoywifi::tickWifiLoop() { } mCnt++; - if(!mScanActive && mBSSIDList.empty()) { // start scanning APs with the given SSID + uint8_t timeout = 10; // seconds + if (mStaConn == CONNECTED) // connected but no ip + timeout = 20; + + + if(!mScanActive && mBSSIDList.empty() && ((mCnt % timeout) == 0)) { // start scanning APs with the given SSID DBGPRINT(F("scanning APs with SSID ")); DBGPRINTLN(String(mConfig->sys.stationSsid)); mScanCnt = 0; @@ -110,20 +115,14 @@ void ahoywifi::tickWifiLoop() { #endif return; } - - uint8_t timeout = 10; // seconds - - if (mStaConn == CONNECTED) // connected but no ip - timeout = 20; - DBGPRINT(F("reconnect in ")); DBGPRINT(String(timeout-mCnt)); DBGPRINTLN(F(" seconds")); if(mScanActive) { getBSSIDs(); - if(!mScanActive) // scan completed - if ((mCnt % timeout) < 8) - mCnt = timeout - 2; + //if(!mScanActive) // scan completed + // if ((mCnt % timeout) < 8) + // mCnt = timeout - 2; } if((mCnt % timeout) == 0) { // try to reconnect after x sec without connection if(mStaConn != CONNECTED)