for debug
Dependencies: HTTPClient PowerControl SNICInterface mbed-rtos mbed-src
Fork of HTTPClient_WiFi_HelloWorld by
Revision 7:c38782801998, committed 2015-05-10
- Comitter:
- MACRUM
- Date:
- Sun May 10 08:51:19 2015 +0000
- Parent:
- 6:bf683c42edf5
- Child:
- 8:0c400a5a28db
- Commit message:
- Added Nucleo-F401RE support
Changed in this revision
--- a/PowerControl.lib Thu Apr 02 02:24:33 2015 +0000 +++ b/PowerControl.lib Sun May 10 08:51:19 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/JST2011/code/PowerControl/#d0fa2aeb02a4 +http://developer.mbed.org/users/MACRUM/code/PowerControl/#9bcf87e81217
--- a/main.cpp Thu Apr 02 02:24:33 2015 +0000 +++ b/main.cpp Sun May 10 08:51:19 2015 +0000 @@ -10,102 +10,99 @@ #define DEMO_AP_SECURITY_TYPE e_SEC_WPA2_AES #define DEMO_AP_SECUTIRY_KEY "PASSWORD" +#if defined(TARGET_LPC1768) C_SNIC_WifiInterface wifi( p9, p10, NC, NC, p30 ); +#elif defined(TARGET_NUCLEO_F401RE) +C_SNIC_WifiInterface wifi( D8, D2, NC, NC, D3); +#elif defined(TARGET_K64F) +C_SNIC_WifiInterface wifi( D1, D0, NC, NC, D2); +#endif -#if defined(_DEBUG) Serial pc(USBTX, USBRX); -#endif HTTPClient http; char str[512]; -int main() +int main() { #if defined(TARGET_LPC1768) PHY_PowerDown(); #endif - wifi.init(); //Use DHCP + pc.printf("WiFi init...\n"); + wifi.init(); wait(0.5); int s = wifi.disconnect(); if( s != 0 ) { return -1; } - + wait(0.3); // Connect AP wifi.connect( DEMO_AP_SSID - , strlen(DEMO_AP_SSID) - , DEMO_AP_SECURITY_TYPE - , DEMO_AP_SECUTIRY_KEY - , strlen(DEMO_AP_SECUTIRY_KEY) ); + , strlen(DEMO_AP_SSID) + , DEMO_AP_SECURITY_TYPE + , DEMO_AP_SECUTIRY_KEY + , strlen(DEMO_AP_SECUTIRY_KEY) ); wait(0.5); - wifi.setIPConfig( true ); - wait(0.5); - printf("IP Address is %s\n", wifi.getIPAddress()); - + wifi.setIPConfig( true ); //Use DHCP + wait(0.5); + pc.printf("IP Address is %s\n", wifi.getIPAddress()); + + int ret = 0; +#if 0 +// disabled this test, since the library doesn't support HTTPS connection //GET data - printf("\nTrying to fetch page...\n"); - int ret = http.get("http://developer.mbed.org/media/uploads/donatien/hello.txt", str, 128); - if (!ret) - { - printf("Page fetched successfully - read %d characters\n", strlen(str)); - printf("Result: %s\n", str); + pc.printf("\nTrying to fetch page...\n"); + ret = http.get("http://developer.mbed.org/media/uploads/donatien/hello.txt", str, 128); + if (!ret) { + pc.printf("Page fetched successfully - read %d characters\n", strlen(str)); + pc.printf("Result: %s\n", str); + } else { + pc.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); } - else - { - printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); - } - +#endif + //POST data HTTPMap map; HTTPText inText(str, 512); map.put("Hello", "World"); map.put("test", "1234"); - printf("\nTrying to post data...\n"); + pc.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); + if (!ret) { + pc.printf("Executed POST successfully - read %d characters\n", strlen(str)); + pc.printf("Result: %s\n", str); + } else { + pc.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); } - 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"); + pc.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); + if (!ret) { + pc.printf("Executed PUT successfully - read %d characters\n", strlen(str)); + pc.printf("Result: %s\n", str); + } else { + pc.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); } - 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"); + pc.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); + if (!ret) { + pc.printf("Executed DELETE successfully - read %d characters\n", strlen(str)); + pc.printf("Result: %s\n", str); + } else { + pc.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); } - else - { - printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); - } - - wifi.disconnect(); + + wifi.disconnect(); while(1) { }
--- a/mbed-rtos.lib Thu Apr 02 02:24:33 2015 +0000 +++ b/mbed-rtos.lib Sun May 10 08:51:19 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#5448826aa700 +http://mbed.org/users/mbed_official/code/mbed-rtos/#85a52b7ef44b
--- a/mbed.bld Thu Apr 02 02:24:33 2015 +0000 +++ b/mbed.bld Sun May 10 08:51:19 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/8ab26030e058 \ No newline at end of file