Skip to content

Commit be817ba

Browse files
authored
Merge pull request #8853 from VeijoPesonen/feature-esp8266_reconnect2
Reports NSAPI_STATUS_CONNECTING when trying to reconnect
2 parents 49a5052 + e092453 commit be817ba

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
@@ -45,6 +45,7 @@ ESP8266::ESP8266(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
4545
_packets_end(&_packets),
4646
_heap_usage(0),
4747
_connect_error(0),
48+
_disconnect(false),
4849
_fail(false),
4950
_sock_already(false),
5051
_closed(false),
@@ -306,6 +307,7 @@ nsapi_error_t ESP8266::connect(const char *ap, const char *passPhrase)
306307
bool ESP8266::disconnect(void)
307308
{
308309
_smutex.lock();
310+
_disconnect = true;
309311
bool done = _parser.send("AT+CWQAP") && _parser.recv("OK\n");
310312
_smutex.unlock();
311313

@@ -1042,7 +1044,12 @@ void ESP8266::_oob_connection_status()
10421044
if (strcmp(status, "GOT IP\n") == 0) {
10431045
_conn_status = NSAPI_STATUS_GLOBAL_UP;
10441046
} else if (strcmp(status, "DISCONNECT\n") == 0) {
1045-
_conn_status = NSAPI_STATUS_DISCONNECTED;
1047+
if (_disconnect) {
1048+
_conn_status = NSAPI_STATUS_DISCONNECTED;
1049+
_disconnect = false;
1050+
} else {
1051+
_conn_status = NSAPI_STATUS_CONNECTING;
1052+
}
10461053
} else if (strcmp(status, "CONNECTED\n") == 0) {
10471054
_conn_status = NSAPI_STATUS_CONNECTING;
10481055
} 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)