@@ -11,6 +11,10 @@ extern "C" {
11
11
#include " WiFiServer.h"
12
12
#include " server_drv.h"
13
13
14
+ #ifdef VERILITE_WDT_MODS
15
+ // watchdog
16
+ #include < avr/wdt.h>
17
+ #endif
14
18
15
19
uint16_t WiFiClient::_srcport = 1024 ;
16
20
@@ -39,8 +43,12 @@ int WiFiClient::connect(IPAddress ip, uint16_t port) {
39
43
unsigned long start = millis ();
40
44
41
45
// wait 4 second for the connection to close
42
- while (!connected () && millis () - start < 10000 )
43
- delay (1 );
46
+ while (!connected () && millis () - start < 10000 ) {
47
+ delay (1 );
48
+ #ifdef VERILITE_WDT_MODS
49
+ wdt_reset (); // watchdog reset
50
+ #endif
51
+ }
44
52
45
53
if (!connected ())
46
54
{
@@ -119,8 +127,12 @@ int WiFiClient::peek() {
119
127
}
120
128
121
129
void WiFiClient::flush () {
122
- while (available ())
123
- read ();
130
+ while (available ()) {
131
+ #ifdef VERILITE_WDT_MODS
132
+ wdt_reset (); // watchdog reset
133
+ #endif
134
+ read ();
135
+ }
124
136
}
125
137
126
138
void WiFiClient::stop () {
@@ -133,8 +145,12 @@ void WiFiClient::stop() {
133
145
134
146
int count = 0 ;
135
147
// wait maximum 5 secs for the connection to close
136
- while (status () != CLOSED && ++count < 50 )
137
- delay (100 );
148
+ while (status () != CLOSED && ++count < 50 ) {
149
+ delay (100 );
150
+ #ifdef VERILITE_WDT_MODS
151
+ wdt_reset (); // watchdog reset
152
+ #endif
153
+ }
138
154
139
155
_sock = 255 ;
140
156
}
@@ -157,6 +173,9 @@ uint8_t WiFiClient::status() {
157
173
if (_sock == 255 ) {
158
174
return CLOSED;
159
175
} else {
176
+ #ifdef VERILITE_WDT_MODS
177
+ wdt_reset (); // watchdog reset
178
+ #endif
160
179
return ServerDrv::getClientState (_sock);
161
180
}
162
181
}
0 commit comments