Skip to content

Commit 782b41f

Browse files
committed
Add correct network status for disconnect
1 parent 3b49dcb commit 782b41f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

libraries/WiFi/src/WiFi.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,17 @@ void arduino::WiFiClass::end() {
108108
disconnect();
109109
}
110110

111-
int arduino::WiFiClass::disconnect() {
111+
int arduino::WiFiClass::disconnect() {
112112
if (_softAP != nullptr) {
113-
static_cast<WhdSoftAPInterface*>(_softAP)->unregister_event_handler();
114-
return static_cast<WhdSoftAPInterface*>(_softAP)->stop();
113+
WhdSoftAPInterface* softAPInterface = static_cast<WhdSoftAPInterface*>(_softAP);
114+
softAPInterface->unregister_event_handler();
115+
_currentNetworkStatus = (softAPInterface->stop() == NSAPI_ERROR_OK ? WL_DISCONNECTED : WL_AP_FAILED);
115116
} else {
116-
return wifi_if->disconnect();
117+
wifi_if->disconnect();
118+
_currentNetworkStatus = WL_DISCONNECTED;
117119
}
118-
_currentNetworkStatus = WL_IDLE_STATUS;
120+
121+
return _currentNetworkStatus;
119122
}
120123

121124
void arduino::WiFiClass::config(arduino::IPAddress local_ip){

0 commit comments

Comments
 (0)