ESP8266: fixes network status refresh procedure

pull/9473/head
Veijo Pesonen 2019-01-23 15:32:33 +02:00
parent 876a397101
commit 71e5321f0f
4 changed files with 13 additions and 11 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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);

View File

@ -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 {