Skip to content

Commit 8332a23

Browse files
committed
fix issue with STA emiting the wrong event
1 parent dde5e29 commit 8332a23

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

libraries/WiFi/src/WiFiGeneric.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,12 @@ esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event)
313313
WiFiSTAClass::_setStatus(WL_DISCONNECTED);
314314
} else if(event->event_id == SYSTEM_EVENT_STA_STOP) {
315315
WiFiSTAClass::_setStatus(WL_NO_SHIELD);
316+
} else if(event->event_id == SYSTEM_EVENT_STA_CONNECTED) {
317+
WiFiSTAClass::_setStatus(WL_IDLE_STATUS);
316318
} else if(event->event_id == SYSTEM_EVENT_STA_GOT_IP) {
317-
WiFiSTAClass::_setStatus(WL_CONNECTED);
319+
if(WiFiSTAClass::status() == WL_IDLE_STATUS) {
320+
WiFiSTAClass::_setStatus(WL_CONNECTED);
321+
}
318322
}
319323

320324
for(uint32_t i = 0; i < cbEventList.size(); i++) {

libraries/WiFi/src/WiFiSTA.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ uint8_t WiFiSTAClass::waitForConnectResult()
358358
return WL_DISCONNECTED;
359359
}
360360
int i = 0;
361-
while(status() >= WL_DISCONNECTED && i++ < 100) {
361+
while((!status() || status() >= WL_DISCONNECTED) && i++ < 100) {
362362
delay(100);
363363
}
364364
return status();

libraries/WiFi/src/WiFiSTA.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class WiFiSTAClass
7272
bool setHostname(const char * hostname);
7373

7474
// STA WiFi info
75-
wl_status_t status();
75+
static wl_status_t status();
7676
String SSID() const;
7777
String psk() const;
7878

0 commit comments

Comments
 (0)