ST / Mbed 2 deprecated HTTPClient_HelloWorld_IDW01M1

Dependencies:   HTTPClient NetworkSocketAPI X_NUCLEO_IDW01M1v2 mbed

Fork of HTTPClient_HelloWorld by ST Expansion SW Team

Example of HTTP and HTTPS connections using X-NUCLEO-IDW01M1 Wi-Fi expansion board.
The application is meant to be used with mbed OS 2 ("Classic") only (no mbedOS 5 support).
For HTTPS connection it uses the TLS/SSL feature provided natively by the Wi-Fi module and performs secure connection to the server also verifying the server identity.
To avoid expired CA certificates, system time (in epoch) must be manually entered (e..g. using http://www.epochconverter.com/ ) .
Retrieval of current time from an NTP server is shown by this example.

Files at this revision

API Documentation at this revision

Comitter:
mapellil
Date:
Tue Nov 08 17:23:18 2016 +0000
Parent:
4:cb85da8d6927
Child:
6:bc2507b7b0de
Commit message:
fixed tests

Changed in this revision

HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
X_NUCLEO_IDW01M1v2.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
--- a/HTTPClient.lib	Mon Nov 07 17:14:14 2016 +0000
+++ b/HTTPClient.lib	Tue Nov 08 17:23:18 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/mapellil/code/HTTPClient/#17578cfdb57a
+https://developer.mbed.org/users/mapellil/code/HTTPClient/#bbbfaf4cc055
--- a/X_NUCLEO_IDW01M1v2.lib	Mon Nov 07 17:14:14 2016 +0000
+++ b/X_NUCLEO_IDW01M1v2.lib	Tue Nov 08 17:23:18 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/mapellil/code/X_NUCLEO_IDW01M1v2/#aa2eaceb3393
+https://developer.mbed.org/users/mapellil/code/X_NUCLEO_IDW01M1v2/#2a8e40fcf80f
--- a/main.cpp	Mon Nov 07 17:14:14 2016 +0000
+++ b/main.cpp	Tue Nov 08 17:23:18 2016 +0000
@@ -26,17 +26,17 @@
     int ret;       
     
     //GET data
-    printf("\nTrying to fetch page...\n");
+    printf("\nTrying to fetch page...\n\r");
     ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128, HTTP_CLIENT_DEFAULT_TIMEOUT);
 //  ret = http.get("http://httpstat.us", str, 128, HTTP_CLIENT_DEFAULT_TIMEOUT);
     if (!ret)
     {
-      printf("Page fetched successfully - read %d characters\n", strlen(str));
+      printf("Page fetched successfully - read %d characters\n\r", strlen(str));
       printf("Result: %s\n", str);
     }
     else
     {
-      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+      printf("Error - ret = %d - HTTP return code = %d\n\r", ret, http.getHTTPResponseCode());
     }
     
     //POST data
@@ -44,43 +44,43 @@
     HTTPText inText(str, 512);
     map.put("Hello", "World");
     map.put("test", "1234");
-    printf("\nTrying to post data...\n");
+    printf("\nTrying to post data...\n\r");
     ret = http.post("http://httpbin.org/post", map, &inText, HTTP_CLIENT_DEFAULT_TIMEOUT);
 //    ret = http.post("http://posttestserver.com/post.php", map, &inText, HTTP_CLIENT_DEFAULT_TIMEOUT);
     if (!ret)
     {
-      printf("Executed POST successfully - read %d characters\n", strlen(str));
-      printf("Result: %s\n", str);
+      printf("Executed POST successfully - read %d characters\n\r", strlen(str));
+      printf("Result: %s\n\r", str);
     }
     else
     {
-      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+      printf("Error - ret = %d - HTTP return code = %d\n\r", 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");
+    printf("\nTrying to put resource...\n\r");
     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);
+      printf("Executed PUT successfully - read %d characters\n\r", strlen(str));
+      printf("Result: %s\n\r", str);
     }
     else
     {
-      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+      printf("Error - ret = %d - HTTP return code = %d\n\r", ret, http.getHTTPResponseCode());
     }
     
     //DELETE data
     //HTTPText inText(str, 512);
-    printf("\nTrying to delete resource...\n");
+    printf("\nTrying to delete resource...\n\r");
     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);
+      printf("Executed DELETE successfully - read %d characters\n\r", strlen(str));
+      printf("Result: %s\n\r", str);
     }
     else
     {