Skip to content

Commit e092453

Browse files
author
Veijo Pesonen
committed
Reports NSAPI_STATUS_CONNECTING when trying to reconnect
1 parent 7995e8b commit e092453

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

components/wifi/esp8266-driver/ESP8266/ESP8266.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ ESP8266::ESP8266(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
4747
_packets_end(&_packets),
4848
_heap_usage(0),
4949
_connect_error(0),
50+
_disconnect(false),
5051
_fail(false),
5152
_sock_already(false),
5253
_closed(false),
@@ -308,6 +309,7 @@ nsapi_error_t ESP8266::connect(const char *ap, const char *passPhrase)
308309
bool ESP8266::disconnect(void)
309310
{
310311
_smutex.lock();
312+
_disconnect = true;
311313
bool done = _parser.send("AT+CWQAP") && _parser.recv("OK\n");
312314
_smutex.unlock();
313315

@@ -1035,7 +1037,12 @@ void ESP8266::_oob_connection_status()
10351037
if (strcmp(status, "GOT IP\n") == 0) {
10361038
_conn_status = NSAPI_STATUS_GLOBAL_UP;
10371039
} else if (strcmp(status, "DISCONNECT\n") == 0) {
1038-
_conn_status = NSAPI_STATUS_DISCONNECTED;
1040+
if (_disconnect) {
1041+
_conn_status = NSAPI_STATUS_DISCONNECTED;
1042+
_disconnect = false;
1043+
} else {
1044+
_conn_status = NSAPI_STATUS_CONNECTING;
1045+
}
10391046
} else if (strcmp(status, "CONNECTED\n") == 0) {
10401047
_conn_status = NSAPI_STATUS_CONNECTING;
10411048
} else {

components/wifi/esp8266-driver/ESP8266/ESP8266.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ class ESP8266 {
428428

429429
// OOB state variables
430430
int _connect_error;
431+
bool _disconnect;
431432
bool _fail;
432433
bool _sock_already;
433434
bool _closed;

0 commit comments

Comments
 (0)