wifi

Dependencies:   HTTPClient NetworkSocketAPI X_NUCLEO_IDW01M1v2 mbed

Fork of HTTPClient_HelloWorld_IDW01M1 by ST

Revision:
3:6e7a93483c12
Parent:
2:270e2d0bb85a
Child:
5:526c0df8cbff
--- 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) {
     }