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
To use it you need to connect your Ethernet correctly. How to do it you may find out at my Ethernet page.
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.
#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);
}
} 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.
Please log in to post a comment.
Where can one find this library please :)