Skip to content

ESP8266WiFiMulti needs a timeout mechanism #3014

Closed
@gavanfantom

Description

@gavanfantom

Basic Infos

Hardware

Hardware: ?ESP-07?
Core Version: ?2.3.0?

Description

When using ESP8266WiFiMulti's run() method to connect to a WiFi network, it is possible for the connection to neither succeed nor fail, leading to the run() method never returning. A good example of this would be connecting to a WiFi network where the DHCP server is inoperative.

A mechanism to specify a timeout should exist.

The relevant code in run() looks like this:

            // wait for connection or fail
            while(status != WL_CONNECTED && status != WL_NO_SSID_AVAIL && status != WL_CONNECT_FAILED) {
                delay(10);
                status = WiFi.status();
            }

I think that simply exiting the loop after a timeout hits would be sufficient - taking the latest status should be harmless and should allow the rest of the code to operate with the most recent information available.

An optional argument specifying a timeout would probably be a good way to implement this. Alternatively, a timeout could be set as member variable by the constructor.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions