Skip to content

Commit 71e5321

Browse files
author
Veijo Pesonen
committed
ESP8266: fixes network status refresh procedure
1 parent 876a397 commit 71e5321

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ ESP8266::ESP8266(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
7474
_parser.oob("UNLINK", callback(this, &ESP8266::_oob_socket_close_err));
7575
_parser.oob("ALREADY CONNECTED", callback(this, &ESP8266::_oob_conn_already));
7676
_parser.oob("ERROR", callback(this, &ESP8266::_oob_err));
77-
_parser.oob("ready", callback(this, &ESP8266::_oob_reset));
77+
_parser.oob("ready", callback(this, &ESP8266::_oob_ready));
7878
// Don't expect to find anything about the watchdog reset in official documentation
7979
//https://techtutorialsx.com/2017/01/21/esp8266-watchdog-functions/
8080
_parser.oob("wdt reset", callback(this, &ESP8266::_oob_watchdog_reset));
@@ -978,7 +978,7 @@ void ESP8266::_oob_watchdog_reset()
978978
"_oob_watchdog_reset() modem watchdog reset triggered\n");
979979
}
980980

981-
void ESP8266::_oob_reset()
981+
void ESP8266::_oob_ready()
982982
{
983983

984984
_rmutex.lock();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ class ESP8266 {
437437
void _oob_watchdog_reset();
438438
void _oob_busy();
439439
void _oob_tcp_data_hdlr();
440-
void _oob_reset();
440+
void _oob_ready();
441441

442442
// OOB state variables
443443
int _connect_error;

components/wifi/esp8266-driver/ESP8266Interface.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ESP8266Interface::ESP8266Interface()
7171

7272
_esp.sigio(this, &ESP8266Interface::event);
7373
_esp.set_timeout();
74-
_esp.attach(this, &ESP8266Interface::update_conn_state_cb);
74+
_esp.attach(this, &ESP8266Interface::refresh_conn_state_cb);
7575

7676
for (int i = 0; i < ESP8266_SOCKET_COUNT; i++) {
7777
_sock_i[i].open = false;
@@ -102,7 +102,7 @@ ESP8266Interface::ESP8266Interface(PinName tx, PinName rx, bool debug, PinName r
102102

103103
_esp.sigio(this, &ESP8266Interface::event);
104104
_esp.set_timeout();
105-
_esp.attach(this, &ESP8266Interface::update_conn_state_cb);
105+
_esp.attach(this, &ESP8266Interface::refresh_conn_state_cb);
106106

107107
for (int i = 0; i < ESP8266_SOCKET_COUNT; i++) {
108108
_sock_i[i].open = false;
@@ -776,15 +776,11 @@ WiFiInterface *WiFiInterface::get_default_instance()
776776

777777
#endif
778778

779-
void ESP8266Interface::update_conn_state_cb()
779+
void ESP8266Interface::refresh_conn_state_cb()
780780
{
781781
nsapi_connection_status_t prev_stat = _conn_stat;
782782
_conn_stat = _esp.connection_status();
783783

784-
if (prev_stat == _conn_stat) {
785-
return;
786-
}
787-
788784
switch (_conn_stat) {
789785
// Doesn't require changes
790786
case NSAPI_STATUS_CONNECTING:
@@ -805,6 +801,12 @@ void ESP8266Interface::update_conn_state_cb()
805801
}
806802
}
807803

804+
if (prev_stat == _conn_stat) {
805+
return;
806+
}
807+
808+
tr_debug("refresh_conn_state_cb(): changed to %d", _conn_stat);
809+
808810
// Inform upper layers
809811
if (_conn_stat_cb) {
810812
_conn_stat_cb(NSAPI_EVENT_CONNECTION_STATUS_CHANGE, _conn_stat);

components/wifi/esp8266-driver/ESP8266Interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class ESP8266Interface : public NetworkStack, public WiFiInterface {
328328
private:
329329
// AT layer
330330
ESP8266 _esp;
331-
void update_conn_state_cb();
331+
void refresh_conn_state_cb();
332332

333333
// HW reset pin
334334
class ResetPin {

0 commit comments

Comments
 (0)