lwIP HTTPClient/HTTPServer
.
I've ported over the lwIP TCP/IP stack to mbed to provide an HTTPClient and HTTPServer. There is no RTOS on the mbed target available so it has to run in the same thread of execution as the application therefore it uses a poll based model. To leave more RAM to the application it shares the network RAM space with the lowlevel driver (ETH RAM on LPC2368, AHBSRAM1 on LPC1768).
It uses the mbed Ethernet class as a back end driver. To use just the Ethernet class have a look _ _here. This is most of enough if you just want to send a UDP packet or broadcast big chunks of data into a network.
Import Library:
http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk
or import precompiled Library:
http://mbed.org/projects/cookbook/svn/EMAC/lwip/precomp
- Full API at http://mbed.org/projects/cookbook/api/EMAC/lwip/trunk
- Full Source at http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk
- Examples at http://mbed.org/projects/cookbook/svn/EMAC/lwip/examples
Ethernet plug
To use it you need to connect your Ethernet correctly. How to do it you may find out at my Ethernet page.
- Full API at http://mbed.org/handbook/Ethernet
HTTPClient
The HTTPClient class provides an easy interface to HTTP GET/POST. You can download files from HTTP servers or update data on your HTTP server.
At the current state it allows the download in normal mode, chunk mode is not denied but the chunks are not recognized. Furthermore the size of the page is currently not detected right, you might get garbage at the end.
A Twitter Hello World
#include "mbed.h" #include "HTTPClient.h" DigitalOut led(LED1); HTTPClient http; const char user[] = "[your twitter username]"; const char pass[] = "[your twitter password]"; const char msg[] = "status=Hello World from an mbed"; const char url[] = "http://twitter.com/statuses/update.xml"; int main(void) { http.auth(user, pass); http.post(url, msg); while(1) { led = !led; wait(0.2); } }
HTTPServer
The HTTPServer class provides an HTTP server for your mbed. You can go to your mbed with your Web browser and access the file system or ask some sensor values.
Development Log
- I observed that the HTTPClient does sometimes not receive a TCP packet. Seems like a problem inside of lwip.
- lwip seems not to handle out of order packages very well.
- The lwip stack tries sometimes to reestablish a connection after a page was successfully delivered.
Tools
Useful tools to debug are:More
4 comments
You need to log in to post a comment
Where can one find this library please :)