mirror of
				https://github.com/esp8266/Arduino.git
				synced 2025-11-03 14:33:37 +03:00 
			
		
		
		
	Edit SD Server example to use the new Write(Stream) method
This commit is contained in:
		@@ -111,23 +111,10 @@ bool loadFromSdCard(String path){
 | 
				
			|||||||
    dataType = 0;
 | 
					    dataType = 0;
 | 
				
			||||||
    path = 0;
 | 
					    path = 0;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    uint8_t obuf[WWW_BUF_SIZE];
 | 
					    if(client.write(dataFile) != dataFile.size()){
 | 
				
			||||||
 | 
					      DBG_OUTPUT_PORT.println("Sent less data than expected!");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    while (dataFile.available() > WWW_BUF_SIZE){
 | 
					 | 
				
			||||||
      dataFile.read(obuf, WWW_BUF_SIZE);
 | 
					 | 
				
			||||||
      if(client.write(obuf, WWW_BUF_SIZE) != WWW_BUF_SIZE){
 | 
					 | 
				
			||||||
        DBG_OUTPUT_PORT.println("Sent less data than expected!");
 | 
					 | 
				
			||||||
        dataFile.close();
 | 
					 | 
				
			||||||
        return true;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    uint16_t leftLen = dataFile.available();
 | 
					 | 
				
			||||||
    dataFile.read(obuf, leftLen);
 | 
					 | 
				
			||||||
    if(client.write(obuf, leftLen) != leftLen){
 | 
					 | 
				
			||||||
      DBG_OUTPUT_PORT.println("Sent less data than expected!");
 | 
					 | 
				
			||||||
      dataFile.close();
 | 
					 | 
				
			||||||
      return true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    dataFile.close();
 | 
					    dataFile.close();
 | 
				
			||||||
    client.stop();
 | 
					    client.stop();
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user