HTTP POST large datasets from the MBED

28 Oct 2011

I am working on an MBED project where I am collecting data to a SD card from a bus of I2C sensors. The data is collected offline. When online the MBED connects a socket to a python server which write the data to a file.

This is all working fine, but require that I have permission to create a listening socket on our rented webserver.

This is not the case, so I am currently researching how to upload data through a normal webserver. (Port 80, using POST requests)

The data amount can be rather large (200MB), so I am forced to upload as a stream of some sort. Perhaps in chunks of a couble of megabytes at a time.

Is it possible to use HTTPClient to do this, or is it restricted to fixed buffer sizes?

Jesper

28 Oct 2011

I think if you implement a custom HTTPData class, you should be able to send it in parts.

28 Oct 2011

Thanx:

Would you happen to know an example I can use for reference?

28 Oct 2011

If you try HTTPClient, please beware that it is not very stable, and has trouble with a lot of servers.

It is also very slow, and your 200Mbyte might take 1 day or even more to upload - for some reason you can only send 1 to 4 packets per second depending on packet size.

In the ethernet driver, I don't think the 1500 byte MTU has been committed in the latest [28] library either, which might mean more packets.

I needed more speed for my application, and had to use direct LwIP API.

If you are only working with 1 server, and you need a special buffer for the large data, I think it is much easier to work with LwIP directly.

The old example of Rolf gives the best idea:

http://mbed.org/projects/cookbook/wiki/EMAC/purehttpc

This LwIP code is much more reliable than the NetServices, and about 20x faster!

Read the LwIP TCP wiki, and you will be in action right away!

http://lwip.wikia.com/wiki/Raw/TCP

28 Oct 2011

I can get hold of the HTTPClient library, but cant find the sourcecode.

I need to look at it or some other code to know how to implement a custom HTTPClient class.

Jesper

28 Oct 2011

An alternative could be to use the raw socket I have working and do the POST header manually?

28 Oct 2011

Thanx Rod. I will dig into it now :)

28 Oct 2011

Using your raw TCP socket, and adding the POST header will be very easy, I think.

Hopefully, you can keep the TCP connection OPEN. For some reason, the tcp_connect() takes a very long time to do!

28 Oct 2011

I agree, but I think I might be forced to implement multipart POST to make it work.

For now I am using the plain socket. It took alot of tweaking to make it perform at a decent speed (7969 B/second), and I dont have too much time to make it work.

Jesper