File tree 1 file changed +11
-3
lines changed
hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/SDWebServer
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -87,12 +87,20 @@ bool loadFromSdCard(String path){
87
87
uint8_t obuf[WWW_BUF_SIZE];
88
88
while (dataFile.available () > WWW_BUF_SIZE){
89
89
dataFile.read (obuf, WWW_BUF_SIZE);
90
- client.write (obuf, WWW_BUF_SIZE);
90
+ if (client.write (obuf, WWW_BUF_SIZE) != WWW_BUF_SIZE){
91
+ Serial.println (" Sent less data than expected!" );
92
+ dataFile.close ();
93
+ return true ;
94
+ }
91
95
}
92
96
// stream the last data left (size is at most WWW_BUF_SIZE bytes)
93
97
uint16_t leftLen = dataFile.available ();
94
98
dataFile.read (obuf, leftLen);
95
- client.write (obuf, leftLen);
99
+ if (client.write (obuf, leftLen) != leftLen){
100
+ Serial.println (" Sent less data than expected!" );
101
+ dataFile.close ();
102
+ return true ;
103
+ }
96
104
97
105
dataFile.close ();
98
106
return true ;
@@ -124,7 +132,7 @@ void setup(void){
124
132
while (WiFi.status () != WL_CONNECTED && i++ < 20 ) delay (500 );
125
133
126
134
// check if we have connected?
127
- if (i == 20 ){
135
+ if (i == 21 ){
128
136
Serial.print (" Could not connect to" );
129
137
Serial.println (ssid);
130
138
// stop execution and wait forever
You can’t perform that action at this time.
0 commit comments