Beispiel HTTP GET

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of IoTKit_HTTPClient by mc-b

Files at this revision

API Documentation at this revision

Comitter:
stefan1691
Date:
Wed Mar 11 13:01:58 2015 +0000
Parent:
2:c9e058ee6f87
Commit message:
Beispiel HTTP GET

Changed in this revision

EthernetInterface.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-rtos.lib 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
diff -r c9e058ee6f87 -r aad64a4b6ff6 EthernetInterface.lib
--- a/EthernetInterface.lib	Mon Jan 19 10:39:52 2015 +0000
+++ b/EthernetInterface.lib	Wed Mar 11 13:01:58 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#d1ccbed7687a
+http://mbed.org/users/mbed_official/code/EthernetInterface/#65b0d840274c
diff -r c9e058ee6f87 -r aad64a4b6ff6 main.cpp
--- a/main.cpp	Mon Jan 19 10:39:52 2015 +0000
+++ b/main.cpp	Wed Mar 11 13:01:58 2015 +0000
@@ -1,33 +1,27 @@
-/** Beispiel fuer Verwendung der HTTP Methoden (GET, POST, PUT, DELETE)
- *
- * Braucht ein Board mit Ethernet
+/** Beispiel HTTP GET
  */
 #include "mbed.h"
 #include "HTTPClient.h"
 #include "HTTPText.h"
 #include "EthernetInterface.h"
 
-Serial pc(USBTX, USBRX);
-
 EthernetInterface eth;
+// HTTPClient Hilfsklasse
 HTTPClient http;
+// I/O Buffer
 char message[6000];
-char str[512];
 
 DigitalOut myled(LED1);
 
 int main()
 {
-    pc.baud(9600);
-    printf("HTTP Client - Build " __DATE__ " - " __TIME__ "\r\n");
+    printf("HTTP Client - GET\n");
     eth.init();
     eth.connect();
 
     while(1) 
     {
         myled = 1;
-        printf( "GET http://developer.mbed.org/media/uploads/mbed_official/hello.txt\n" );
-        //int ret = http.get("https://raw.githubusercontent.com/mc-b/microHOME/master/README.md", message, sizeof(message));
         int ret = http.get("http://developer.mbed.org/media/uploads/mbed_official/hello.txt", message, sizeof(message));
         if ( !ret ) 
         {
@@ -39,48 +33,7 @@
         
         myled = 0;
 
-        //POST data
-        HTTPMap map;
-        HTTPText inText(str, 512);
-        map.put("Hello", "World");
-        map.put("test", "1234");
-        printf("\nTrying to post data...\n");
-        ret = http.post("http://httpbin.org/post", map, &inText);
-        if ( ! ret ) 
-        {
-            printf("Executed POST successfully - read %d characters\n", strlen(str));
-            printf("Result: %s\n", str);
-        } 
-        else 
-        {
-            printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-        }
-
-        //PUT data
-        strcpy(str, "This is a PUT test!");
-        HTTPText outText(str);
-        //HTTPText inText(str, 512);
-        printf("\nTrying to put resource...\n");
-        ret = http.put("http://httpbin.org/put", outText, &inText);
-        if (!ret) {
-            printf("Executed PUT successfully - read %d characters\n", strlen(str));
-            printf("Result: %s\n", str);
-        } else {
-            printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-        }
-
-        //DELETE data
-        //HTTPText inText(str, 512);
-        printf("\nTrying to delete resource...\n");
-        ret = http.del("http://httpbin.org/delete", &inText);
-        if (!ret) {
-            printf("Executed DELETE successfully - read %d characters\n", strlen(str));
-            printf("Result: %s\n", str);
-        } else {
-            printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-        }
-
         wait(10);
     }
-    // eth.disconnect();
+    eth.disconnect();
 }
diff -r c9e058ee6f87 -r aad64a4b6ff6 mbed-rtos.lib
--- a/mbed-rtos.lib	Mon Jan 19 10:39:52 2015 +0000
+++ b/mbed-rtos.lib	Wed Mar 11 13:01:58 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#9387d4c49609
+http://mbed.org/users/mbed_official/code/mbed-rtos/#63988a2238f7
diff -r c9e058ee6f87 -r aad64a4b6ff6 mbed.bld
--- a/mbed.bld	Mon Jan 19 10:39:52 2015 +0000
+++ b/mbed.bld	Wed Mar 11 13:01:58 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/7e07b6fb45cf
\ No newline at end of file