Working sample program from the [[http://mbed.org/cookbook/Cool-Components-Workshop-Board|cool components workshop board]] page.
Dependencies: NetServices mbed
Revision 0:f0d3d3f90a84, committed 2011-01-19
- Comitter:
- hlipka
- Date:
- Wed Jan 19 20:39:50 2011 +0000
- Commit message:
- initial version
Changed in this revision
diff -r 000000000000 -r f0d3d3f90a84 NetServices.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NetServices.lib Wed Jan 19 20:39:50 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/segundo/code/NetServices/#4e2468d7d5cb
diff -r 000000000000 -r f0d3d3f90a84 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jan 19 20:39:50 2011 +0000 @@ -0,0 +1,46 @@ +#include "mbed.h" +#include "HTTPClient.h" +#include "EthernetNetIf.h" + +DigitalOut led(LED1); + +EthernetNetIf eth; + + +LocalFileSystem local("local"); +/** + * Request a google search for HelloWorld and display the first 2000 characters + * of the page source on the serial terminal. + */ +int main(void) { +EthernetNetIf eth( // Brings up the device with static IP address and domain name. + IpAddr(192,168,0,123), // IPv4 address + IpAddr(255,255,255,0), // netmask + IpAddr(192,168,0,1), // default gateway + IpAddr(192,168,0,1)); // dns server + int ethErr = eth.setup(); // Brings up the device with static IP address and domain name. + if(ethErr) + { + printf("Error %d in setup.\n", ethErr); + return -1; + } + + HTTPClient http; + HTTPText txt; + + HTTPResult r = http.get("http://mbed.org/media/uploads/donatien/hello.txt", &txt); + if(r==HTTP_OK) + { + printf("Result :\"%s\"\n", txt.gets()); + } + else + { + printf("Error %d\n", r); + } + + // Work is done! + while(1) { + led = !led; + wait(0.2); + } +}
diff -r 000000000000 -r f0d3d3f90a84 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jan 19 20:39:50 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e