Dependencies:   EthernetNetIf mbed

Dependents:   SuperTweet_get

Files at this revision

API Documentation at this revision

Comitter:
donatien
Date:
Mon Jun 14 13:36:01 2010 +0000
Child:
1:e6e8b074e675
Commit message:

Changed in this revision

EthernetNetIf.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClientStreamingExample.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/EthernetNetIf.lib	Mon Jun 14 13:36:01 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient.lib	Mon Jun 14 13:36:01 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/HTTPClient/#d97a4fc01c86
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClientStreamingExample.cpp	Mon Jun 14 13:36:01 2010 +0000
@@ -0,0 +1,64 @@
+#include "mbed.h"
+#include "EthernetNetIf.h"
+#include "HTTPClient.h"
+
+EthernetNetIf eth; 
+HTTPClient http;
+
+HTTPResult result;
+bool completed = false;
+void request_callback(HTTPResult r)
+{
+  result = r;
+  completed = true;
+}
+
+int main() {
+
+  printf("Start\n");
+
+  printf("Setting up...\n");
+  EthernetErr ethErr = eth.setup();
+  if(ethErr)
+  {
+    printf("Error %d in setup.\n", ethErr);
+    return -1;
+  }
+  printf("Setup OK\n");
+  
+  HTTPStream stream;
+  
+  char BigBuf[512 + 1] = {0};
+  stream.readNext((byte*)BigBuf, 512); //Point to buffer for the first read
+  
+  HTTPResult r = http.get("HTTP://hackaday.com/feed/", &stream, request_callback); //Load a very large page, such as the hackaday RSS feed
+  
+  while(!completed)
+  {
+    Net::poll(); //Polls the Networking stack
+    if(stream.readable())
+    {
+      BigBuf[stream.readLen()] = 0; //Transform this buffer in a zero-terminated char* string
+      printf("%s",BigBuf); //Display it while loading
+      //Note: some servers do not like if you throttle them too much, so printf'ing during a request is generally bad practice
+      stream.readNext((byte*)BigBuf, 512); //Buffer has been read, now we can put more data in it
+    }
+  }
+  printf("\n--------------\n");
+  if(result == HTTP_OK)
+  {
+    printf("Read completely\n"); 
+  }
+  else
+  {
+    printf("Error %d\n", result);
+  }
+  
+  while(1)
+  {
+  
+  }
+  
+  return 0;
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jun 14 13:36:01 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/029aa53d7323