Skip to content

Commit 59e224d

Browse files
committed
Add correct network status for disconnect
1 parent 3b49dcb commit 59e224d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

libraries/WiFi/src/WiFi.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,15 @@ void arduino::WiFiClass::end() {
110110

111111
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)