I'm working with a Realtek Ameba IoT RTL8195 board that's compatible to Arduino.
I have a text file on an SD card that I want to send via HTTP over wifi, with the Ameba acting as a server.
I combined the SD card example with the web server example. There's no LED involved here.
Upon request from a client, I want to shove the whole content of the text file into a text/plain
response as quickly as possible. At the moment i have a 18.7KB dummy file that takes 6.3s to download in the broswer total. That's rather slow.
My code looks essentially like this:
while (file.available() > 0)
{
client.print((char)file.read());
}
client.flush();
Where file
is declared as SdFatFile file = fs.open(absolute_filename);
and client
is WiFiClient client = server.available();
. Which are both classes that come with the Ameba Arduino SDK.
Both of them extend Stream
. I wonder if reading and writing both streams byte by byte causes a bottleneck. is there a way to simply write "the whole thing" to client
?