diff --git a/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp b/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp index 77d7430a94..30db14c9b6 100644 --- a/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp +++ b/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp @@ -74,7 +74,7 @@ ESP8266::ESP8266(PinName tx, PinName rx, bool debug, PinName rts, PinName cts) _parser.oob("UNLINK", callback(this, &ESP8266::_oob_socket_close_err)); _parser.oob("ALREADY CONNECTED", callback(this, &ESP8266::_oob_conn_already)); _parser.oob("ERROR", callback(this, &ESP8266::_oob_err)); - _parser.oob("ready", callback(this, &ESP8266::_oob_reset)); + _parser.oob("ready", callback(this, &ESP8266::_oob_ready)); // Don't expect to find anything about the watchdog reset in official documentation //https://techtutorialsx.com/2017/01/21/esp8266-watchdog-functions/ _parser.oob("wdt reset", callback(this, &ESP8266::_oob_watchdog_reset)); @@ -978,7 +978,7 @@ void ESP8266::_oob_watchdog_reset() "_oob_watchdog_reset() modem watchdog reset triggered\n"); } -void ESP8266::_oob_reset() +void ESP8266::_oob_ready() { _rmutex.lock(); diff --git a/components/wifi/esp8266-driver/ESP8266/ESP8266.h b/components/wifi/esp8266-driver/ESP8266/ESP8266.h index e977c0cb38..68688243bf 100644 --- a/components/wifi/esp8266-driver/ESP8266/ESP8266.h +++ b/components/wifi/esp8266-driver/ESP8266/ESP8266.h @@ -437,7 +437,7 @@ private: void _oob_watchdog_reset(); void _oob_busy(); void _oob_tcp_data_hdlr(); - void _oob_reset(); + void _oob_ready(); // OOB state variables int _connect_error; diff --git a/components/wifi/esp8266-driver/ESP8266Interface.cpp b/components/wifi/esp8266-driver/ESP8266Interface.cpp index 6e6331f992..ba9730eacc 100644 --- a/components/wifi/esp8266-driver/ESP8266Interface.cpp +++ b/components/wifi/esp8266-driver/ESP8266Interface.cpp @@ -71,7 +71,7 @@ ESP8266Interface::ESP8266Interface() _esp.sigio(this, &ESP8266Interface::event); _esp.set_timeout(); - _esp.attach(this, &ESP8266Interface::update_conn_state_cb); + _esp.attach(this, &ESP8266Interface::refresh_conn_state_cb); for (int i = 0; i < ESP8266_SOCKET_COUNT; i++) { _sock_i[i].open = false; @@ -102,7 +102,7 @@ ESP8266Interface::ESP8266Interface(PinName tx, PinName rx, bool debug, PinName r _esp.sigio(this, &ESP8266Interface::event); _esp.set_timeout(); - _esp.attach(this, &ESP8266Interface::update_conn_state_cb); + _esp.attach(this, &ESP8266Interface::refresh_conn_state_cb); for (int i = 0; i < ESP8266_SOCKET_COUNT; i++) { _sock_i[i].open = false; @@ -776,15 +776,11 @@ WiFiInterface *WiFiInterface::get_default_instance() #endif -void ESP8266Interface::update_conn_state_cb() +void ESP8266Interface::refresh_conn_state_cb() { nsapi_connection_status_t prev_stat = _conn_stat; _conn_stat = _esp.connection_status(); - if (prev_stat == _conn_stat) { - return; - } - switch (_conn_stat) { // Doesn't require changes case NSAPI_STATUS_CONNECTING: @@ -805,6 +801,12 @@ void ESP8266Interface::update_conn_state_cb() } } + if (prev_stat == _conn_stat) { + return; + } + + tr_debug("refresh_conn_state_cb(): changed to %d", _conn_stat); + // Inform upper layers if (_conn_stat_cb) { _conn_stat_cb(NSAPI_EVENT_CONNECTION_STATUS_CHANGE, _conn_stat); diff --git a/components/wifi/esp8266-driver/ESP8266Interface.h b/components/wifi/esp8266-driver/ESP8266Interface.h index 0dc77c9f7d..f253172e56 100644 --- a/components/wifi/esp8266-driver/ESP8266Interface.h +++ b/components/wifi/esp8266-driver/ESP8266Interface.h @@ -328,7 +328,7 @@ protected: private: // AT layer ESP8266 _esp; - void update_conn_state_cb(); + void refresh_conn_state_cb(); // HW reset pin class ResetPin {