mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 02:52:11 +01:00
Fix WiFi setup
* Increased the number of APs that can be queried and filtered out those that have an RSSI -95. Previously, the number of returned SSIDs could blow the output buffer. * Do not disable the Save button during scan of potential APs. If the scan is taking a long time you should just be able to type it in. * If a connection is lost and cannot be recovered fall back to AP mode to allow resetting the creds without power off.
This commit is contained in:
parent
dcd90a4c29
commit
e1aada23b0
3 changed files with 46 additions and 22 deletions
26
Network.cpp
26
Network.cpp
|
|
@ -15,6 +15,7 @@ extern SocketEmitter sockEmit;
|
|||
extern MQTTClass mqtt;
|
||||
extern rebootDelay_t rebootDelay;
|
||||
|
||||
int connectRetries = 0;
|
||||
void Network::end() {
|
||||
sockEmit.end();
|
||||
SSDP.end();
|
||||
|
|
@ -34,11 +35,21 @@ bool Network::setup() {
|
|||
}
|
||||
void Network::loop() {
|
||||
if(millis() - this->lastEmit > 1500) {
|
||||
if(this->connect()) {}
|
||||
while(!this->connect()) {
|
||||
// If we lost our connenction
|
||||
connectRetries++;
|
||||
if(connectRetries > 100) {
|
||||
this->openSoftAP();
|
||||
break;
|
||||
}
|
||||
sockEmit.loop();
|
||||
}
|
||||
connectRetries = 0;
|
||||
this->lastEmit = millis();
|
||||
this->emitSockets();
|
||||
if(WiFi.status() != WL_CONNECTED) return;
|
||||
}
|
||||
else sockEmit.loop();
|
||||
sockEmit.loop();
|
||||
if(settings.WIFI.ssdpBroadcast) {
|
||||
if(!SSDP.isStarted) SSDP.begin();
|
||||
SSDP.loop();
|
||||
|
|
@ -147,7 +158,7 @@ bool Network::connect() {
|
|||
Serial.print(this->channel);
|
||||
Serial.print(" (");
|
||||
Serial.print(this->strength);
|
||||
Serial.print("dbm) ");
|
||||
Serial.println("dbm) ");
|
||||
}
|
||||
else Serial.println("Connecting to AP");
|
||||
this->connectAttempts++;
|
||||
|
|
@ -274,17 +285,10 @@ bool Network::openSoftAP() {
|
|||
|
||||
while ((WiFi.status() != WL_CONNECTED))
|
||||
{
|
||||
for(int i = 0; i < 3; i++) {
|
||||
//delay(100);
|
||||
//digitalWrite(LED_BUILTIN, HIGH);
|
||||
//delay(100);
|
||||
//digitalWrite(LED_BUILTIN, LOW);
|
||||
}
|
||||
int clients = WiFi.softAPgetStationNum();
|
||||
|
||||
webServer.loop();
|
||||
if(millis() - this->lastEmit > 1500) {
|
||||
if(this->connect()) {}
|
||||
//if(this->connect()) {}
|
||||
this->lastEmit = millis();
|
||||
this->emitSockets();
|
||||
if(clients > 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue