comunicazione wifi

Dependencies:   NetworkSocketAPI X_NUCLEO_IDW01M1v2 mbed

Fork of HelloWorld_IDW01M1v2 by ST

Files at this revision

API Documentation at this revision

Comitter:
gianluigiprimavera
Date:
Mon Mar 05 14:36:40 2018 +0000
Parent:
12:80d8e97e81f2
Commit message:
prova

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Jan 16 13:26:50 2017 +0000
+++ b/main.cpp	Mon Mar 05 14:36:40 2018 +0000
@@ -58,8 +58,8 @@
 
 int main() {
     int err;    
-    char * ssid = "STM";
-    char * seckey = "STMDemo";  
+    char * ssid = "primavera";
+    char * seckey = "Prisco2006";  
     
     pc.printf("\r\nX-NUCLEO-IDW01M1 mbed Application\r\n");     
     pc.printf("\r\nconnecting to AP\r\n");
@@ -77,24 +77,41 @@
     pc.printf("\r\nIP Address is: %s\r\n", (ip) ? ip : "No IP");
     pc.printf("\r\nMAC Address is: %s\r\n", (mac) ? mac : "No MAC");    
     
-    SocketAddress addr(&spwf, "st.com");   
+    SocketAddress addr(&spwf, "192.168.10.100");   
     pc.printf("\r\nst.com resolved to: %s\r\n", addr.get_ip_address());    
 
     pc.printf("\r\nconnecting to http://4.ifcfg.me\r\n");
-    
     TCPSocket socket(&spwf);
-    err = socket.connect("4.ifcfg.me", 23);
+    err = socket.connect("192.168.10.100", 1500);
+
     if(err!=0) 
     {
       pc.printf("\r\nCould not connect to Socket, err = %d!!\r\n", err); 
       return -1;
     } else pc.printf("\r\nconnected to host server\r\n"); 
-    
+
     char buffer[100];
     int count = 0;
+    count = socket.send("aaaa",sizeof buffer);
+/*    socket.close();
     pc.printf("\r\nReceiving Data\r\n"); 
+    count =0;
+   pc.printf("\r\nIP Address is: %s\r\n", (ip) ? ip : "No IP");
+    pc.printf("\r\nMAC Address is: %s\r\n", (mac) ? mac : "No MAC");    
+    
+   SocketAddress addr2(&spwf, "192.168.10.100");   
+    pc.printf("\r\nst.com resolved to: %s\r\n", addr2.get_ip_address());    
+
+    pc.printf("\r\nconnecting to http://4.ifcfg.me\r\n");
+    TCPSocket socket2(&spwf);
+    err = socket2.connect("192.168.10.100", 1500);
+
+    if(err!=0) 
+    {
+      pc.printf("\r\nCould not connect to Socket, err = %d!!\r\n", err); 
+      return -1;
+    } else pc.printf("\r\nconnected to host server\r\n"); */
     count = socket.recv(buffer, sizeof buffer);
-    
     if(count > 0)
     {
         buffer [count]='\0';
@@ -103,6 +120,8 @@
     else pc.printf("\r\nData not received\r\n");
 
     pc.printf("\r\nClosing Socket\r\n");
+
+    
     socket.close();
     pc.printf("\r\nUnsecure Socket Test complete.\r\n");
     printf ("Socket closed\n\r");
--- a/mbed.bld	Mon Jan 16 13:26:50 2017 +0000
+++ b/mbed.bld	Mon Mar 05 14:36:40 2018 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/7130f322cb7e
\ No newline at end of file