Skip to content

Commit ab1a511

Browse files
author
Veijo Pesonen
committed
Fixes disconnect to not rely on C++11
1 parent 1c3fe4e commit ab1a511

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

ESP8266Interface.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,16 @@ int ESP8266Interface::set_channel(uint8_t channel)
250250

251251
int ESP8266Interface::disconnect()
252252
{
253-
return _esp.disconnect() ? NSAPI_ERROR_OK : NSAPI_ERROR_DEVICE_ERROR;
253+
int ret = _esp.disconnect() ? NSAPI_ERROR_OK : NSAPI_ERROR_DEVICE_ERROR;
254+
255+
if (ret == NSAPI_ERROR_OK) {
256+
// Try to lure the nw status update from ESP8266, might come later
257+
_esp.bg_process_oob(ESP8266_RECV_TIMEOUT, true);
258+
// In case the status update arrives later
259+
_conn_stat = NSAPI_STATUS_DISCONNECTED;
260+
}
261+
262+
return ret;
254263
}
255264

256265
const char *ESP8266Interface::get_ip_address()
@@ -640,9 +649,6 @@ void ESP8266Interface::attach(mbed::Callback<void(nsapi_event_t, intptr_t)> stat
640649

641650
nsapi_connection_status_t ESP8266Interface::get_connection_status() const
642651
{
643-
if (_initialized) {
644-
_esp.bg_process_oob(ESP8266_RECV_TIMEOUT, true);
645-
}
646652
return _conn_stat;
647653
}
648654

ESP8266Interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class ESP8266Interface : public NetworkStack, public WiFiInterface
332332

333333
private:
334334
// AT layer
335-
mutable ESP8266 _esp;
335+
ESP8266 _esp;
336336
void update_conn_state_cb();
337337

338338
// Credentials

0 commit comments

Comments
 (0)