Skip to content

Commit fccb98f

Browse files
author
Veijo Pesonen
committed
Resets driver on watchdog reset (SW or HW)
1 parent 0e890b7 commit fccb98f

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
@@ -59,6 +59,12 @@ ESP8266::ESP8266(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
5959
_parser.oob("WIFI ", callback(this, &ESP8266::_oob_connection_status));
6060
_parser.oob("UNLINK", callback(this, &ESP8266::_oob_socket_close_err));
6161
_parser.oob("ALREADY CONNECTED", callback(this, &ESP8266::_oob_conn_already));
62+
// Don't expect to find anything about the watchdog reset in official documentation
63+
//https://techtutorialsx.com/2017/01/21/esp8266-watchdog-functions/
64+
_parser.oob("wdt reset", callback(this, &ESP8266::_oob_watchdog_reset));
65+
// Don't see a reason to make distiction between software(Software WDT reset) and hardware(wdt reset) watchdog treatment
66+
//https://github.com/esp8266/Arduino/blob/4897e0006b5b0123a2fa31f67b14a3fff65ce561/doc/faq/a02-my-esp-crashes.md#watchdog
67+
_parser.oob("Soft WDT reset", callback(this, &ESP8266::_oob_watchdog_reset));
6268

6369
for(int i= 0; i < SOCKET_COUNT; i++) {
6470
_sock_i[i].open = false;
@@ -797,6 +803,16 @@ bool ESP8266::_recv_ap(nsapi_wifi_ap_t *ap)
797803
return ret;
798804
}
799805

806+
void ESP8266::_oob_watchdog_reset()
807+
{
808+
for (int i = 0; i < SOCKET_COUNT; i++) {
809+
_sock_i[i].open = false;
810+
}
811+
812+
_conn_status = NSAPI_STATUS_DISCONNECTED;
813+
_conn_stat_cb();
814+
}
815+
800816
void ESP8266::_oob_connect_err()
801817
{
802818
_fail = false;

ESP8266/ESP8266.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ class ESP8266
395395
void _oob_socket4_closed();
396396
void _oob_connection_status();
397397
void _oob_socket_close_err();
398+
void _oob_watchdog_reset();
398399

399400
// OOB state variables
400401
int _connect_error;

0 commit comments

Comments
 (0)