Skip to content

Commit db4076f

Browse files
committed
add more debug for disconnect
add isConnected function for easier usage
1 parent 00cd8e6 commit db4076f

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void ESP8266WiFiGenericClass::_eventCallback(void* arg) {
106106
DEBUGV("wifi evt: %d\n", event->event);
107107

108108
if(event->event == EVENT_STAMODE_DISCONNECTED) {
109+
DEBUGV("STA disconnect: %d\n", event->event_info.disconnected.reason);
109110
WiFiClient::stopAll();
110111
}
111112

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ bool ESP8266WiFiSTAClass::disconnect(bool wifioff) {
267267
return ret;
268268
}
269269

270+
/**
271+
* is STA interface connected?
272+
* @return true if STA is connected to an AD
273+
*/
274+
bool ESP8266WiFiSTAClass::isConnected() {
275+
return (status() == WL_CONNECTED);
276+
}
277+
278+
270279
/**
271280
* Setting the ESP8266 station to connect to the AP (which is recorded)
272281
* automatically or not when powered on. Enable auto-connect by default.

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class ESP8266WiFiSTAClass {
4444
bool reconnect();
4545
bool disconnect(bool wifioff = false);
4646

47+
bool isConnected();
48+
4749
bool setAutoConnect(bool autoConnect);
4850
bool getAutoConnect();
4951

0 commit comments

Comments
 (0)