WizFi250 Tcp Udp Example

Dependencies:   WizFi250Interface mbed

Fork of WizFi250TcpUdpExample by DongEun Koak

Revision:
4:eb659522d69a
Parent:
3:390016675fc8
--- a/main.cpp	Tue Jun 23 01:23:15 2015 +0000
+++ b/main.cpp	Wed Oct 21 04:59:52 2015 +0000
@@ -23,16 +23,17 @@
 
 
 #define SECURE WizFi250::SEC_AUTO
-#define SSID "wizohp"
-#define PASS "wiznet218"
+#define SSID "DIR-815_Wiznet"
+#define PASS "12345678"
 
-#define ECHO_SERVER_ADDRESS "192.168.15.14"
+#define ECHO_SERVER_ADDRESS "192.168.18.105"
 #define ECHO_SERVER_PORT    5000
 
 #if defined(TARGET_FRDM_KL25Z)
     WizFi250Interface wizfi250(PTE0,PTE1,PTD5,PTD0,PTD4,NC,115200);
-#else
+#elif defined(TARGET_WIZwiki_W7500)
     WizFi250Interface wizfi250(D0,D1,D7,D8,PA_12,NC,115200);
+    Serial pc(USBTX, USBRX);
 #endif
 
 
@@ -44,40 +45,43 @@
 
 int main()
 {
-        int i;
-        char input;
-        
-        wizfi250.init();
-        if ( wizfi250.connect(SECURE, SSID, PASS))      return -1;
-        printf("IP Address is %s\r\n", wizfi250.getIPAddress());
-
-
-        while(1)
+    char input;
+    
+    pc.baud(115200);
+    
+    wizfi250.init();
+    if ( wizfi250.connect(SECURE, SSID, PASS))      return -1;
+    printf("IP Address is %s\r\n", wizfi250.getIPAddress());
+    
+    
+    while(1)
+    {
+        printf("\r\nInput Test Mode ( 1:)\r\n");
+        input = pc.getc();
+    
+        if(input == 'q')
+            break;
+    
+        switch(input)
         {
-            printf("\r\nInput Test Mode ( 1:)\r\n");
-            scanf("%c",&input);
-
-            if(input == 'q')
-                break;
-
-            switch(input)
-            {
-            case '1':
-                testTcpEchoServer();
-                break;
-            case '2':
-                testTcpEchoClient();
-                break;
-            case '3':
-                testUdpEchoClient();
-                break;
-            case '4':
-                testUdpEchoServer();
-                break;
-            }
+        case '1':
+            testTcpEchoServer();
+            break;
+        case '2':
+            testTcpEchoClient();
+            break;
+        case '3':
+            testUdpEchoClient();
+            break;
+        case '4':
+            testUdpEchoServer();
+            break;
+        default:
+            break;        
         }
-
-        printf("End the test program\r\n");
+    }
+    
+    printf("End the test program\r\n");
 }
 
 
@@ -101,9 +105,9 @@
         if( client.is_connected() == false )
         {
             client.close();
+            server.close();
             break;
         }
-
         n = client.receive_all(buffer, sizeof(buffer));
         if ( n > 0 )
         {
@@ -190,4 +194,4 @@
     }
 
     socket.close();
-}
\ No newline at end of file
+}