Include scan with SoftAP operation #407 #410

This commit is contained in:
Robert Strouse 2024-06-25 18:04:46 -07:00
parent 9205723125
commit e04d7e3fc7
9 changed files with 26 additions and 10 deletions

1
.gitignore vendored
View file

@ -7,3 +7,4 @@ debug.cfg
SomfyController.ino.XIAO_ESP32S3.bin
SomfyController.ino.esp32c3.bin
SomfyController.ino.esp32s2.bin
.vscode/settings.json

View file

@ -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,

View file

@ -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;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
2.4.5
2.4.6

View file

@ -8,9 +8,9 @@
<meta name="apple-mobile-web-app-title" content="ESPSomfy RTS App">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="main.css?v=2.4.5c" type="text/css" />
<link rel="stylesheet" href="widgets.css?v=2.4.5c" type="text/css" />
<link rel="stylesheet" href="icons.css?v=2.4.5c" type="text/css" />
<link rel="stylesheet" href="main.css?v=2.4.6c" type="text/css" />
<link rel="stylesheet" href="widgets.css?v=2.4.6c" type="text/css" />
<link rel="stylesheet" href="icons.css?v=2.4.6c" type="text/css" />
<link rel="icon" type="image/png" href="favicon.png" />
<!-- iPad retina icon -->
@ -114,7 +114,7 @@
rel="apple-touch-startup-image">
<script type="text/javascript" src="index.js?v=2.4.5c"></script>
<script type="text/javascript" src="index.js?v=2.4.6c"></script>
</head>
<body>
<div id="divContainer" class="container main" data-auth="false">

View file

@ -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;