
Updated version of HTTPClient test
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
Fork of HTTPClient_HelloWorld by
Revision 3:c90fdafaa113, committed 2015-02-18
- Comitter:
- bridadan
- Date:
- Wed Feb 18 23:48:12 2015 +0000
- Parent:
- 2:270e2d0bb85a
- Commit message:
- Changed Get URL, used updated HTTPClient library, and kept ethernet connection open for pinging.
Changed in this revision
diff -r 270e2d0bb85a -r c90fdafaa113 EthernetInterface.lib --- a/EthernetInterface.lib Thu Aug 30 15:42:06 2012 +0000 +++ b/EthernetInterface.lib Wed Feb 18 23:48:12 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/EthernetInterface/#a0ee3ae75cfa +http://mbed.org/users/mbed_official/code/EthernetInterface/#65b0d840274c
diff -r 270e2d0bb85a -r c90fdafaa113 HTTPClient.lib --- a/HTTPClient.lib Thu Aug 30 15:42:06 2012 +0000 +++ b/HTTPClient.lib Wed Feb 18 23:48:12 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/code/HTTPClient/#1f743885e7de +http://developer.mbed.org/users/MACRUM/code/HTTPClient/#3c7789c521df
diff -r 270e2d0bb85a -r c90fdafaa113 main.cpp --- 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) { } }
diff -r 270e2d0bb85a -r c90fdafaa113 mbed-rtos.lib --- a/mbed-rtos.lib Thu Aug 30 15:42:06 2012 +0000 +++ b/mbed-rtos.lib Wed Feb 18 23:48:12 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#9654a71f5a90 +http://mbed.org/users/mbed_official/code/mbed-rtos/#83e169389a69
diff -r 270e2d0bb85a -r c90fdafaa113 mbed.bld --- a/mbed.bld Thu Aug 30 15:42:06 2012 +0000 +++ b/mbed.bld Wed Feb 18 23:48:12 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/976df7c37ad5 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac \ No newline at end of file