@@ -58,6 +58,7 @@ ESP8266Interface::ESP8266Interface()
58
58
_if_blocking(true ),
59
59
_if_connected(_cmutex),
60
60
_initialized(false ),
61
+ _connect_retval(NSAPI_ERROR_OK),
61
62
_conn_stat(NSAPI_STATUS_DISCONNECTED),
62
63
_conn_stat_cb(NULL ),
63
64
_global_event_queue(NULL ),
@@ -187,18 +188,19 @@ void ESP8266Interface::_connect_async()
187
188
_cmutex.unlock ();
188
189
return ;
189
190
}
190
-
191
- if (_esp.connect (ap_ssid, ap_pass) != NSAPI_ERROR_OK) {
191
+ _connect_retval = _esp.connect (ap_ssid, ap_pass);
192
+ if (_connect_retval == NSAPI_ERROR_OK || _connect_retval == NSAPI_ERROR_AUTH_FAILURE
193
+ || _connect_retval == NSAPI_ERROR_NO_SSID) {
194
+ _connect_event_id = 0 ;
195
+ _if_connected.notify_all ();
196
+ } else {
192
197
// Postpone to give other stuff time to run
193
198
_connect_event_id = _global_event_queue->call_in (ESP8266_CONNECT_TIMEOUT, callback (this , &ESP8266Interface::_connect_async));
194
199
195
200
if (!_connect_event_id) {
196
201
MBED_ERROR (MBED_MAKE_ERROR (MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
197
202
" _connect_async(): unable to add event to queue" );
198
203
}
199
- } else {
200
- _connect_event_id = 0 ;
201
- _if_connected.notify_all ();
202
204
}
203
205
_cmutex.unlock ();
204
206
}
@@ -235,6 +237,7 @@ int ESP8266Interface::connect()
235
237
236
238
_cmutex.lock ();
237
239
240
+ _connect_retval = NSAPI_ERROR_NO_CONNECTION;
238
241
MBED_ASSERT (!_connect_event_id);
239
242
_connect_event_id = _global_event_queue->call (callback (this , &ESP8266Interface::_connect_async));
240
243
@@ -243,13 +246,14 @@ int ESP8266Interface::connect()
243
246
" connect(): unable to add event to queue" );
244
247
}
245
248
246
- while (_if_blocking && (_conn_status_to_error () != NSAPI_ERROR_IS_CONNECTED)) {
249
+ while (_if_blocking && (_conn_status_to_error () != NSAPI_ERROR_IS_CONNECTED)
250
+ && (_connect_retval == NSAPI_ERROR_NO_CONNECTION)) {
247
251
_if_connected.wait ();
248
252
}
249
253
250
254
_cmutex.unlock ();
251
255
252
- return NSAPI_ERROR_OK ;
256
+ return _connect_retval ;
253
257
}
254
258
255
259
int ESP8266Interface::set_credentials (const char *ssid, const char *pass, nsapi_security_t security)
0 commit comments