Working sample program from the [[http://mbed.org/cookbook/Cool-Components-Workshop-Board|cool components workshop board]] page.

Dependencies:   NetServices mbed

Files at this revision

API Documentation at this revision

Comitter:
hlipka
Date:
Wed Jan 19 20:39:50 2011 +0000
Commit message:
initial version

Changed in this revision

NetServices.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /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);
+  }
+}
--- /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