by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Diff: main.cpp
- Revision:
- 0:6dbcb68a18e4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Jun 16 15:32:31 2013 +0000 @@ -0,0 +1,22 @@ +/* Program Example 12.9: mbed HTTP client test + */ +#include "mbed.h" +#include "EthernetNetIf.h" +#include "HTTPClient.h" +EthernetNetIf eth( + IpAddr(192,168,0,101), //IP Address + IpAddr(255,255,255,0), //Network Mask + IpAddr(192,168,0,1), //Gateway + IpAddr(192,168,0,1) //DNS +); +HTTPClient http; +HTTPText txt; +Serial pc (USBTX,USBRX) ; +int main() { + pc.printf("\r\nSetting up network connection...\n\r"); + eth.setup(); + pc.printf("\r\nSetup OK. Queerying data...\r\n"); + // attempt to access file ‘mbedclienttest.txt’ through the internet... + HTTPResult r=http.get("http://www.rt60.co.uk/mbed/mbedclienttest.txt", &txt); + pc.printf("Result :\n\r\"%s\"\n\r", txt.gets()); +}