NNN40_WiFi_Demo

Dependencies:   WIFI_API_32kRAM mbed

Fork of NNN40_WiFi by Delta

Revision:
11:0d4c4bc2274a
Parent:
10:fff1a8a4b003
diff -r fff1a8a4b003 -r 0d4c4bc2274a main.cpp
--- a/main.cpp	Thu Jul 02 03:10:05 2015 +0000
+++ b/main.cpp	Thu Aug 20 02:54:14 2015 +0000
@@ -10,77 +10,69 @@
 
 DigitalOut LED01(p13);
 DigitalOut LED02(p7);
+Serial pc(USBTX, USBRX);//debug port , 9600
 
 
 int main(void)
 {   
-
+      
     EthernetInterface eth;
     eth.init(); //Use DHCP
     wait(1);
-    DPRINT(N_ERR, "Hello World, NNN40_WiFi\n");
+    printf( "Hello World, NNN40_WiFi\n");
     // set given SSID and PW as the highest priority  
     //wifi.setNetwork("KORYO-Guest", "koryo123", 0);
-    wifi.setNetwork("Gordon Airport Network", "password", 0);
+    wifi.setNetwork("Airport123", "12345678", 0);
     wait(1);
    
     eth.connect(40000);
-    DPRINT(N_ERR, "****IP Address:%s\n",eth.getIPAddress());
-    DPRINT(N_ERR, "****MAC Address:%s\n",eth.getMACAddress());
+    printf("****IP Address:%s\n",eth.getIPAddress());
+    printf("****MAC Address:%s\n",eth.getMACAddress());
 
-    LED01 = 1;
-    TCPSocketConnection socket1;     
+  
+    
+    TCPSocketConnection socket1; 
+    printf("Connect to %s:%d\n",PC_SERVER_ADDRESS_1,PC_PORT);    
     if(0 == socket1.connect(PC_SERVER_ADDRESS_1,PC_PORT))
     {
-         
-         DPRINT(N_ERR, "****socket1 connect ok!!!\n");
+         LED01 = 1;
+         printf("****socket1 connect ok!!!\n");
     }
     else
     {
-        DPRINT(N_ERR, "****socket connect1 failed !!\n");
+        printf("****socket connect1 failed !!\n");
     }
    
-    TCPSocketConnection socket2;     
+    TCPSocketConnection socket2;   
+    printf("Connect to %s:%d\n",PC_SERVER_ADDRESS_2,PC_PORT);     
     if(0 == socket2.connect(PC_SERVER_ADDRESS_2,PC_PORT))
     {
          
          LED02 = 1;
-         DPRINT(N_ERR, "****socket2 connect ok!!!\n");
+         printf("****socket2 connect ok!!!\n");
     }
     else
     {
-        DPRINT(N_ERR, "****socke2 connect failed !!\n");
+        printf("****socke2 connect failed !!\n");
     }
    
     char msg[] = "Hello World";
     char buf[1024];
-    //socket.send(msg, sizeof(msg));
-
-    /*
-    if(socket.receive(rx, sizeof(msg)) != -1)
-    {
-         DPRINT(N_ERR, "****RX data :%s\n",&rx[0]);
-    }
-    else
-    {
-         DPRINT(N_ERR, "****RX error\n");
-    }
-    */
+    
     int i = 1;
     while(1)
     {
         wait(1);
         int j = sprintf(buf, "Hello World : %d\n",i);
-        DPRINT(N_ERR, "******************Send Message : %d \n", i++);
-        //socket.send(msg, sizeof(msg));   
+        printf("******************Send Message : %d \n", i++);
         socket1.send(buf, j);    
         socket2.send(buf, j);   
         
         if(i%2 == 0 )  LED02 = 1;
         else LED02 = 0; 
     }
-    DPRINT(N_ERR, "****socket close \n");
-    socket1.close();
+    printf("****socket close \n");
+    //socket1.close();
     //socket2.close();
     eth.disconnect();
     wifi.sleep();