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)

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?

  • You may try if doing it line by line is faster. Or in chunks of 500bytes (or whatever amount of RAM you have available) – Paul Oct 26 '16 at 17:13

Paul's suggestion from the comment worked. Increasing the buffer reduced the overall time to a couple hundred ms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.