Skip to content

Commit 14517ce

Browse files
rtrbtMattiasTF
authored andcommitted
Remove automatic reconnect if first connect after startup fails.
1 parent 5982674 commit 14517ce

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

libraries/WiFi/src/STA.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ static void _onStaArduinoEvent(arduino_event_t *ev) {
106106
if (_sta_network_if == NULL || ev->event_id < ARDUINO_EVENT_WIFI_STA_START || ev->event_id > ARDUINO_EVENT_WIFI_STA_LOST_IP) {
107107
return;
108108
}
109-
static bool first_connect = true;
110109
log_v("Arduino STA Event: %d - %s", ev->event_id, Network.eventName(ev->event_id));
111110

112111
if (ev->event_id == ARDUINO_EVENT_WIFI_STA_START) {
@@ -137,7 +136,7 @@ static void _onStaArduinoEvent(arduino_event_t *ev) {
137136
log_w("Reason: %u - %s", reason, WiFi.STA.disconnectReasonName((wifi_err_reason_t)reason));
138137
if (reason == WIFI_REASON_NO_AP_FOUND) {
139138
_sta_network_if->_setStatus(WL_NO_SSID_AVAIL);
140-
} else if ((reason == WIFI_REASON_AUTH_FAIL) && !first_connect) {
139+
} else if ((reason == WIFI_REASON_AUTH_FAIL)) {
141140
_sta_network_if->_setStatus(WL_CONNECT_FAILED);
142141
} else if (reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) {
143142
_sta_network_if->_setStatus(WL_CONNECTION_LOST);
@@ -149,10 +148,6 @@ static void _onStaArduinoEvent(arduino_event_t *ev) {
149148

150149
bool DoReconnect = false;
151150
if (reason == WIFI_REASON_ASSOC_LEAVE) { //Voluntarily disconnected. Don't reconnect!
152-
} else if (first_connect) { //Retry once for all failure reasons
153-
first_connect = false;
154-
DoReconnect = true;
155-
log_d("WiFi Reconnect Running");
156151
} else if (_sta_network_if->getAutoReconnect() && _is_staReconnectableReason(reason)) {
157152
DoReconnect = true;
158153
log_d("WiFi AutoReconnect Running");

0 commit comments

Comments
 (0)