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:
Mon Nov 07 17:09:30 2016 +0000
Parent:
2:270e2d0bb85a
Child:
4:cb85da8d6927
Commit message:
first beta committ

Changed in this revision

EthernetInterface.lib Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
NetworkSocketAPI.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
mbed-rtos.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.lib	Thu Aug 30 15:42:06 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#a0ee3ae75cfa
--- a/HTTPClient.lib	Thu Aug 30 15:42:06 2012 +0000
+++ b/HTTPClient.lib	Mon Nov 07 17:09:30 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/donatien/code/HTTPClient/#1f743885e7de
+http://mbed.org/users/donatien/code/HTTPClient/#17578cfdb57a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NetworkSocketAPI.lib	Mon Nov 07 17:09:30 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/NetworkSocketAPI/code/NetworkSocketAPI/#ea3a618e0818
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IDW01M1v2.lib	Mon Nov 07 17:09:30 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/X_NUCLEO_IDW01M1v2/#b607968f8676
--- a/main.cpp	Thu Aug 30 15:42:06 2012 +0000
+++ b/main.cpp	Mon Nov 07 17:09:30 2016 +0000
@@ -1,20 +1,34 @@
 #include "mbed.h"
-#include "EthernetInterface.h"
+//#include "EthernetInterface.h"
+#include "TCPSocket.h"
 #include "HTTPClient.h"
 
+#ifdef LICIO
+
+#else
 EthernetInterface eth;
-HTTPClient http;
+#endif
+
 char str[512];
 
 int main() 
 {
-    eth.init(); //Use DHCP
+#ifdef LICIO
+    SpwfSAInterface spwf(D8, D2, false);    
 
+    HTTPWiFi ipstack(spwf, "crespan","Elfrontal1", NSAPI_SECURITY_WPA2);
+ 
+HTTPClient http(ipstack);
+#else    
+    eth.init(); //Use DHCP
     eth.connect();
+#endif 
+    int ret;       
     
     //GET data
     printf("\nTrying to fetch page...\n");
-    int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
+    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));
@@ -31,7 +45,8 @@
     map.put("Hello", "World");
     map.put("test", "1234");
     printf("\nTrying to post data...\n");
-    ret = http.post("http://httpbin.org/post", map, &inText);
+    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));
@@ -72,7 +87,7 @@
       printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
     }
     
-    eth.disconnect();  
+//    eth.disconnect();  
 
     while(1) {
     }
--- a/mbed-rtos.lib	Thu Aug 30 15:42:06 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#9654a71f5a90
--- a/mbed.bld	Thu Aug 30 15:42:06 2012 +0000
+++ b/mbed.bld	Mon Nov 07 17:09:30 2016 +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/2e9cc70d1897
\ No newline at end of file