mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-07-28 18:03:45 +02:00
make connection timeout configurable
This commit is contained in:
@@ -34,6 +34,9 @@ const unsigned long LOOP_TIMEOUT = 2000;
|
||||
bool WifiInterface::connected = false;
|
||||
Stream * WifiInterface::wifiStream;
|
||||
|
||||
#ifndef WIFI_CONNECT_TIMEOUT
|
||||
#define WIFI_CONNECT_TIMEOUT 8000
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -172,7 +175,7 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F
|
||||
// ESP8266 is preconfigured. We check the first 13 chars
|
||||
// of the password.
|
||||
if (strncmp_P("Your network ",(const char*)password,13) == 0) {
|
||||
delay(8000); // give a preconfigured ES8266 a chance to connect to a router
|
||||
delay(WIFI_CONNECT_TIMEOUT); // give a preconfigured ES8266 a chance to connect to a router
|
||||
|
||||
StringFormatter::send(wifiStream, F("AT+CIFSR\r\n"));
|
||||
if (checkForOK(5000, (const char*) F("+CIFSR:STAIP"), true,false))
|
||||
@@ -191,7 +194,7 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F
|
||||
// AT command early version supports CWJAP/CWSAP
|
||||
if (SSid) {
|
||||
StringFormatter::send(wifiStream, F("AT+CWJAP=\"%S\",\"%S\"\r\n"), SSid, password);
|
||||
ipOK = checkForOK(8000, OK_SEARCH, true);
|
||||
ipOK = checkForOK(WIFI_CONNECT_TIMEOUT, OK_SEARCH, true);
|
||||
}
|
||||
DIAG(F("\n**\n"));
|
||||
|
||||
@@ -203,7 +206,7 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F
|
||||
|
||||
if (SSid) {
|
||||
StringFormatter::send(wifiStream, F("AT+CWJAP_CUR=\"%S\",\"%S\"\r\n"), SSid, password);
|
||||
ipOK = checkForOK(8000, OK_SEARCH, true);
|
||||
ipOK = checkForOK(WIFI_CONNECT_TIMEOUT, OK_SEARCH, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +246,7 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F
|
||||
|
||||
int i=0;
|
||||
do StringFormatter::send(wifiStream, F("AT+CWSAP=\"DCCEX_%s\",\"PASS_%s\",1,4\r\n"), macTail, macTail);
|
||||
while (i++<2 && !checkForOK(8000, OK_SEARCH, true)); // do twice if necessary but ignore failure as AP mode may still be ok
|
||||
while (i++<2 && !checkForOK(WIFI_CONNECT_TIMEOUT, OK_SEARCH, true)); // do twice if necessary but ignore failure as AP mode may still be ok
|
||||
|
||||
} else {
|
||||
|
||||
|
Reference in New Issue
Block a user