Skip to content

Commit

Permalink
Fixes disconnect to not rely on C++11
Browse files Browse the repository at this point in the history
  • Loading branch information
Veijo Pesonen committed Oct 26, 2018
1 parent 1c3fe4e commit ab1a511
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions ESP8266Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,16 @@ int ESP8266Interface::set_channel(uint8_t channel)

int ESP8266Interface::disconnect()
{
return _esp.disconnect() ? NSAPI_ERROR_OK : NSAPI_ERROR_DEVICE_ERROR;
int ret = _esp.disconnect() ? NSAPI_ERROR_OK : NSAPI_ERROR_DEVICE_ERROR;

if (ret == NSAPI_ERROR_OK) {
// Try to lure the nw status update from ESP8266, might come later
_esp.bg_process_oob(ESP8266_RECV_TIMEOUT, true);
// In case the status update arrives later
_conn_stat = NSAPI_STATUS_DISCONNECTED;
}

return ret;
}

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

nsapi_connection_status_t ESP8266Interface::get_connection_status() const
{
if (_initialized) {
_esp.bg_process_oob(ESP8266_RECV_TIMEOUT, true);
}
return _conn_stat;
}

Expand Down
2 changes: 1 addition & 1 deletion ESP8266Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class ESP8266Interface : public NetworkStack, public WiFiInterface

private:
// AT layer
mutable ESP8266 _esp;
ESP8266 _esp;
void update_conn_state_cb();

// Credentials
Expand Down

0 comments on commit ab1a511

Please sign in to comment.