Skip to content

WiFi.begin "aligned with Arduino.cc". blocking (breaking change) #9063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
}
}

if (beginTimeout) {
return (wl_status_t) waitForConnectResult(beginTimeout);
}
return status();
}

Expand Down Expand Up @@ -344,6 +347,9 @@ wl_status_t WiFiSTAClass::begin()
}
}

if (beginTimeout) {
return (wl_status_t) waitForConnectResult(beginTimeout);
}
return status();
}

Expand Down
8 changes: 8 additions & 0 deletions libraries/WiFi/src/WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,20 @@ class WiFiSTAClass

static void _setStatus(wl_status_t status);

void setBeginTimeout(unsigned long timeout) {
beginTimeout = timeout;
}
void setBeginAsync() {
beginTimeout = 0;
}

protected:
static bool _useStaticIp;
static bool _autoReconnect;
static wifi_auth_mode_t _minSecurity;
static wifi_scan_method_t _scanMethod;
static wifi_sort_method_t _sortMethod;
unsigned long beginTimeout = 60000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 minute timeout is absolutely unusable.
10% of it might be something to consider, but a default timeout of 60 seconds is hardly every usable in the world of microcontrollers.

As was already mentioned, a default of 0 would be at least non-breaking, but then you explicitly need to set the timeout and if you would change your code to do so, then you probably already have a similar loop right after the call to WiFi.begin()


public:
bool beginSmartConfig(smartconfig_type_t type = SC_TYPE_ESPTOUCH, char* crypt_key = NULL);
Expand Down