mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-25 20:02:37 +03:00
fixes for sd server example
This commit is contained in:
parent
8819c1e91c
commit
1cb920f713
@ -87,12 +87,20 @@ bool loadFromSdCard(String path){
|
|||||||
uint8_t obuf[WWW_BUF_SIZE];
|
uint8_t obuf[WWW_BUF_SIZE];
|
||||||
while (dataFile.available() > WWW_BUF_SIZE){
|
while (dataFile.available() > WWW_BUF_SIZE){
|
||||||
dataFile.read(obuf, WWW_BUF_SIZE);
|
dataFile.read(obuf, WWW_BUF_SIZE);
|
||||||
client.write(obuf, WWW_BUF_SIZE);
|
if(client.write(obuf, WWW_BUF_SIZE) != WWW_BUF_SIZE){
|
||||||
|
Serial.println("Sent less data than expected!");
|
||||||
|
dataFile.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//stream the last data left (size is at most WWW_BUF_SIZE bytes)
|
//stream the last data left (size is at most WWW_BUF_SIZE bytes)
|
||||||
uint16_t leftLen = dataFile.available();
|
uint16_t leftLen = dataFile.available();
|
||||||
dataFile.read(obuf, leftLen);
|
dataFile.read(obuf, leftLen);
|
||||||
client.write(obuf, leftLen);
|
if(client.write(obuf, leftLen) != leftLen){
|
||||||
|
Serial.println("Sent less data than expected!");
|
||||||
|
dataFile.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
dataFile.close();
|
dataFile.close();
|
||||||
return true;
|
return true;
|
||||||
@ -124,7 +132,7 @@ void setup(void){
|
|||||||
while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500);
|
while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500);
|
||||||
|
|
||||||
//check if we have connected?
|
//check if we have connected?
|
||||||
if(i == 20){
|
if(i == 21){
|
||||||
Serial.print("Could not connect to");
|
Serial.print("Could not connect to");
|
||||||
Serial.println(ssid);
|
Serial.println(ssid);
|
||||||
//stop execution and wait forever
|
//stop execution and wait forever
|
||||||
|
Loading…
x
Reference in New Issue
Block a user