diff --git a/.gitignore b/.gitignore index 8eec9f2..be96788 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ debug.cfg SomfyController.ino.XIAO_ESP32S3.bin SomfyController.ino.esp32c3.bin SomfyController.ino.esp32s2.bin +.vscode/settings.json diff --git a/ConfigSettings.h b/ConfigSettings.h index f5a5d0a..5613f65 100644 --- a/ConfigSettings.h +++ b/ConfigSettings.h @@ -3,7 +3,7 @@ #ifndef configsettings_h #define configsettings_h #include "WResp.h" -#define FW_VERSION "v2.4.5" +#define FW_VERSION "v2.4.6" enum class conn_types_t : byte { unset = 0x00, wifi = 0x01, diff --git a/Network.cpp b/Network.cpp index 8025e69..5b9649c 100644 --- a/Network.cpp +++ b/Network.cpp @@ -58,7 +58,18 @@ void Network::loop() { } } sockEmit.loop(); - if(this->connected() && millis() - this->lastMDNS > 60000) { + if(this->softAPOpened) { + // If the softAP has been opened check to see if there are any clients connected. If there is not + // then we need to scan for the SSID. + if(settings.connType == conn_types_t::wifi && strlen(settings.WIFI.ssid) > 0 && WiFi.softAPgetStationNum() == 0) { + // We do not have any connections to the SoftAP so we should be able to scan. For now if we are already scanning + // then we will not start another scan. + if(!_apScanning && WiFi.scanNetworks(true, false, true, 300, 0, settings.WIFI.ssid) == -1) { + _apScanning = true; + } + } + } + else if(this->connected() && millis() - this->lastMDNS > 60000) { // Every 60 seconds we are going to look at wifi connectivity // to get around the roaming issues with ESP32. We will try to do this in an async manner. If // there is a channel that is better we will stop the wifi radio and reconnect @@ -73,7 +84,7 @@ void Network::loop() { this->lastMDNS = millis(); } if(_apScanning) { - if(!settings.WIFI.roaming || this->connType != conn_types_t::wifi || this->softAPOpened) _apScanning = false; + if(!settings.WIFI.roaming || settings.connType != conn_types_t::wifi || (this->softAPOpened && WiFi.softAPgetStationNum() != 0)) _apScanning = false; else { uint16_t n = WiFi.scanComplete(); if( n > 0) { @@ -82,6 +93,10 @@ void Network::loop() { if(this->getStrongestAP(settings.WIFI.ssid, bssid, &channel)) { if(memcmp(bssid, WiFi.BSSID(), sizeof(bssid)) != 0) { Serial.printf("Found stronger AP %d %02X:%02X:%02X:%02X:%02X:%02X\n", channel, bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); + if(this->softAPOpened) { + WiFi.softAPdisconnect(true); + WiFi.mode(WIFI_STA); + } this->changeAP(bssid, channel); } } @@ -530,7 +545,7 @@ bool Network::openSoftAP() { Serial.println(); Serial.println("Turning the HotSpot On"); esp_task_wdt_reset(); // Make sure we do not reboot here. - WiFi.softAP("ESPSomfy RTS", ""); + WiFi.softAP(strlen(settings.hostname) > 0 ? settings.hostname : "ESPSomfy RTS", ""); Serial.println("Initializing AP for credentials modification"); delay(200); return true; diff --git a/SomfyController.ino.esp32.bin b/SomfyController.ino.esp32.bin index 4e613d7..8a509b1 100644 Binary files a/SomfyController.ino.esp32.bin and b/SomfyController.ino.esp32.bin differ diff --git a/SomfyController.ino.esp32s3.bin b/SomfyController.ino.esp32s3.bin index 1c00b7e..9780134 100644 Binary files a/SomfyController.ino.esp32s3.bin and b/SomfyController.ino.esp32s3.bin differ diff --git a/SomfyController.littlefs.bin b/SomfyController.littlefs.bin index a05cd1a..cb3dbe5 100644 Binary files a/SomfyController.littlefs.bin and b/SomfyController.littlefs.bin differ diff --git a/data/appversion b/data/appversion index 26f8b8b..62e6420 100644 --- a/data/appversion +++ b/data/appversion @@ -1 +1 @@ -2.4.5 \ No newline at end of file +2.4.6 \ No newline at end of file diff --git a/data/index.html b/data/index.html index 41be767..1376f48 100644 --- a/data/index.html +++ b/data/index.html @@ -8,9 +8,9 @@ - - - + + + @@ -114,7 +114,7 @@ rel="apple-touch-startup-image"> - +
diff --git a/data/index.js b/data/index.js index dd38ade..99b1100 100644 --- a/data/index.js +++ b/data/index.js @@ -1270,7 +1270,7 @@ var security = new Security(); class General { initialized = false; - appVersion = 'v2.4.5'; + appVersion = 'v2.4.6'; reloadApp = false; init() { if (this.initialized) return;