How to send big data to an HTTP server where the client has limited RAM?

119 Views Asked by At

I am designing a temperature and humidity logging system using microcontrollers and embedded C. The system sends the data to the server using GET method (could be POST,too) whenever it gathers a new data from the sensors. Whenever the power and/or the internet is gone, it logs to an SD card.

I want to send these logged data to the server whenever the internet comes back. When sent separately, each of my request is as follows and it takes about 5 seconds to complete even on my local network.

GET /add.php?userID=0000mac=000:000:000:000:000:000&id=0000000000sensor=000&temp=%2B000.000&hum=000.000 HTTP/1.1\r\nHost: 192.168.10.25\r\n\r\n

However, since my available RAM is very limited to only about 400 bytes in this microcontroller, I cannot buffer and send all the logged data in one request.

For an electricity/internet loss of 2 days, about 3000 of data set is logged. How do I send these to the server in a very quick way?

1

There are 1 best solutions below

3
On

Well I think a simple for loop will do it. Here is the pseudocode:

foreach(loggedRequest){
    loadTheRequestFromTheLogFile();
    sendTheDataForThisRequest(); // Hang here until the server returns a response
    clearMemoryFromPreviousRequest();
}

By waiting for the server's response, you will be sure that the data got to the server as well as that you will not have the ram full.

You can also go with an inner for loop with a fixed number of requests and then wait for all their responses. This will be faster but you have to do multiple tests to be sure you're not reaching to the ram limit.