mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
make connection timeout configurable
This commit is contained in:
parent
89b158f3d1
commit
a3ddcb059a
|
@ -34,6 +34,9 @@ const unsigned long LOOP_TIMEOUT = 2000;
|
||||||
bool WifiInterface::connected = false;
|
bool WifiInterface::connected = false;
|
||||||
Stream * WifiInterface::wifiStream;
|
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
|
// ESP8266 is preconfigured. We check the first 13 chars
|
||||||
// of the password.
|
// of the password.
|
||||||
if (strncmp_P("Your network ",(const char*)password,13) == 0) {
|
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"));
|
StringFormatter::send(wifiStream, F("AT+CIFSR\r\n"));
|
||||||
if (checkForOK(5000, (const char*) F("+CIFSR:STAIP"), true,false))
|
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
|
// AT command early version supports CWJAP/CWSAP
|
||||||
if (SSid) {
|
if (SSid) {
|
||||||
StringFormatter::send(wifiStream, F("AT+CWJAP=\"%S\",\"%S\"\r\n"), SSid, password);
|
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"));
|
DIAG(F("\n**\n"));
|
||||||
|
|
||||||
|
@ -203,7 +206,7 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F
|
||||||
|
|
||||||
if (SSid) {
|
if (SSid) {
|
||||||
StringFormatter::send(wifiStream, F("AT+CWJAP_CUR=\"%S\",\"%S\"\r\n"), SSid, password);
|
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;
|
int i=0;
|
||||||
do StringFormatter::send(wifiStream, F("AT+CWSAP=\"DCCEX_%s\",\"PASS_%s\",1,4\r\n"), macTail, macTail);
|
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 {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,13 @@ The configuration file for DCC++ EX Command Station
|
||||||
#define WIFI_SSID "Your network name"
|
#define WIFI_SSID "Your network name"
|
||||||
#define WIFI_PASSWORD "Your network passwd"
|
#define WIFI_PASSWORD "Your network passwd"
|
||||||
#define WIFI_HOSTNAME "dccex"
|
#define WIFI_HOSTNAME "dccex"
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Wifi connect timeout in milliseconds. Default is 8000 (8 seconds). You only need
|
||||||
|
// to set this if you have an extremely slow Wifi router.
|
||||||
|
//
|
||||||
|
//#define WIFI_CONNECT_TIMEOUT 8000
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue
Block a user