Skip to content

Commit 234d9e0

Browse files
author
Veijo Pesonen
committed
Resets driver on watchdog reset (SW or HW)
1 parent 471beb5 commit 234d9e0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ESP8266/ESP8266.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ ESP8266::ESP8266(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
6060
_parser.oob("UNLINK", callback(this, &ESP8266::_oob_socket_close_err));
6161
_parser.oob("ALREADY CONNECTED", callback(this, &ESP8266::_oob_conn_already));
6262
_parser.oob("ERROR", callback(this, &ESP8266::_oob_err));
63+
// Don't expect to find anything about the watchdog reset in official documentation
64+
//https://techtutorialsx.com/2017/01/21/esp8266-watchdog-functions/
65+
_parser.oob("wdt reset", callback(this, &ESP8266::_oob_watchdog_reset));
66+
// Don't see a reason to make distiction between software(Software WDT reset) and hardware(wdt reset) watchdog treatment
67+
//https://github.com/esp8266/Arduino/blob/4897e0006b5b0123a2fa31f67b14a3fff65ce561/doc/faq/a02-my-esp-crashes.md#watchdog
68+
_parser.oob("Soft WDT reset", callback(this, &ESP8266::_oob_watchdog_reset));
6369

6470
for(int i= 0; i < SOCKET_COUNT; i++) {
6571
_sock_i[i].open = false;
@@ -820,6 +826,16 @@ bool ESP8266::_recv_ap(nsapi_wifi_ap_t *ap)
820826
return ret;
821827
}
822828

829+
void ESP8266::_oob_watchdog_reset()
830+
{
831+
for (int i = 0; i < SOCKET_COUNT; i++) {
832+
_sock_i[i].open = false;
833+
}
834+
835+
_conn_status = NSAPI_STATUS_DISCONNECTED;
836+
_conn_stat_cb();
837+
}
838+
823839
void ESP8266::_oob_connect_err()
824840
{
825841
_fail = false;

ESP8266/ESP8266.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ class ESP8266
396396
void _oob_socket4_closed();
397397
void _oob_connection_status();
398398
void _oob_socket_close_err();
399+
void _oob_watchdog_reset();
399400

400401
// OOB state variables
401402
int _connect_error;

0 commit comments

Comments
 (0)