Update WiFiMulti.cpp (#1220)
* Update WiFiMulti.cpp added 5 sec timeout from ESP8266 * Update WiFiMulti.cpp * Update WiFiMulti.h
This commit is contained in:
parent
7eb6fc5286
commit
2ded419486
@ -42,7 +42,7 @@ bool WiFiMulti::addAP(const char* ssid, const char *passphrase)
|
|||||||
return APlistAdd(ssid, passphrase);
|
return APlistAdd(ssid, passphrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WiFiMulti::run(void)
|
uint8_t WiFiMulti::run(uint32_t connectTimeout)
|
||||||
{
|
{
|
||||||
|
|
||||||
int8_t scanResult;
|
int8_t scanResult;
|
||||||
@ -118,8 +118,9 @@ uint8_t WiFiMulti::run(void)
|
|||||||
WiFi.begin(bestNetwork.ssid, bestNetwork.passphrase, bestChannel, bestBSSID);
|
WiFi.begin(bestNetwork.ssid, bestNetwork.passphrase, bestChannel, bestBSSID);
|
||||||
status = WiFi.status();
|
status = WiFi.status();
|
||||||
|
|
||||||
// wait for connection or fail
|
auto startTime = millis();
|
||||||
while(status != WL_CONNECTED && status != WL_NO_SSID_AVAIL && status != WL_CONNECT_FAILED) {
|
// wait for connection, fail, or timeout
|
||||||
|
while(status != WL_CONNECTED && status != WL_NO_SSID_AVAIL && status != WL_CONNECT_FAILED && (millis() - startTime) <= connectTimeout) {
|
||||||
delay(10);
|
delay(10);
|
||||||
status = WiFi.status();
|
status = WiFi.status();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
bool addAP(const char* ssid, const char *passphrase = NULL);
|
bool addAP(const char* ssid, const char *passphrase = NULL);
|
||||||
|
|
||||||
uint8_t run(void);
|
uint8_t run(uint32_t connectTimeout=5000);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<WifiAPlist_t> APlist;
|
std::vector<WifiAPlist_t> APlist;
|
||||||
|
Loading…
Reference in New Issue
Block a user