Updated version of HTTPClient test

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed

Fork of HTTPClient_HelloWorld by Donatien Garnier

Revision:
3:c90fdafaa113
Parent:
2:270e2d0bb85a
--- a/main.cpp	Thu Aug 30 15:42:06 2012 +0000
+++ b/main.cpp	Wed Feb 18 23:48:12 2015 +0000
@@ -8,17 +8,27 @@
 
 int main() 
 {
+    printf("Initializing ethernet\n");
     eth.init(); //Use DHCP
-
-    eth.connect();
+    printf("Initialization complete. Attempting to connect...\n");
+    
+    if (eth.connect() < 0) {
+        // Error
+        printf("Error! Ethernet failed to connect.\n");
+    } else {
+        // Success
+        printf("Ethernet connected successfully.\n");
+        printf("IP Address: %s\n", eth.getIPAddress());
+        printf("Gateway: %s\n", eth.getGateway());
+        printf("MAC Address %s\n", eth.getMACAddress());
+    }    
     
     //GET data
     printf("\nTrying to fetch page...\n");
-    int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
+    int ret = http.get("http://httpbin.org/get", str, 128);
     if (!ret)
     {
       printf("Page fetched successfully - read %d characters\n", strlen(str));
-      printf("Result: %s\n", str);
     }
     else
     {
@@ -35,7 +45,6 @@
     if (!ret)
     {
       printf("Executed POST successfully - read %d characters\n", strlen(str));
-      printf("Result: %s\n", str);
     }
     else
     {
@@ -51,7 +60,6 @@
     if (!ret)
     {
       printf("Executed PUT successfully - read %d characters\n", strlen(str));
-      printf("Result: %s\n", str);
     }
     else
     {
@@ -65,15 +73,16 @@
     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());
     }
     
-    eth.disconnect();  
-
+    printf("Keeping ethernet connection open for pinging\n");
+    printf("IP Address: %s\n", eth.getIPAddress());
+    printf("Gateway: %s\n", eth.getGateway());
+    printf("MAC Address %s\n", eth.getMACAddress());
     while(1) {
     }
 }