NuMaker Ethernet TCP

Revision:
2:291ff97f421e
Parent:
1:621d4620acd2
Child:
3:861e6f618bd3
--- a/main.cpp	Mon Sep 19 10:07:18 2016 +0000
+++ b/main.cpp	Mon Sep 19 11:57:16 2016 +0000
@@ -15,31 +15,24 @@
 #endif
 #endif
 
-//#define DEMO_STATIC_IP
+
 //#define LOCAL_LAN
 
 namespace {
     // Test connection information
-#ifndef DEMO_STATIC_IP
-    #ifndef LOCAL_LAN
+#ifndef LOCAL_LAN
 const char *HTTP_SERVER_NAME = "developer.mbed.org";
-    #else
-const char *HTTP_SERVER_NAME = "pt22_winserver2.nuvoton.com";
-    #endif
 #else
-const char *HTTP_SERVER_NAME = "N/A";
-const char *HTTP_SERVER_IP = "10.28.10.54";
-const char *STATIC_IP = "10.28.10.99";
-const char *STATIC_MASK = "255.255.255.0";
-const char *DEFAULT_GATEWAY = "10.28.10.254";
+const char *HTTP_SERVER_NAME = "pt22_winserver2.nuvoton.com";
 #endif
-    #ifndef LOCAL_LAN
+
+#ifndef LOCAL_LAN
 const char *HTTP_SERVER_FILE_PATH = "/media/uploads/mbed_official/hello.txt";
 const int HTTP_SERVER_PORT = 80;
-    #else
+#else
 const char *HTTP_SERVER_FILE_PATH = "/examples/arm_mbed/hello.txt";
 const int HTTP_SERVER_PORT = 8080;
-    #endif
+#endif
 
 #if defined(TARGET_VK_RZ_A1H)
     const int RECV_BUFFER_SIZE = 300;
@@ -61,34 +54,25 @@
 }
 
 int main() {
-    printf(" 100 \r\n");
+    printf(" Start TCP test \r\n");
 //    GREENTEA_SETUP(20, "default_auto");
-    printf(" 200 \r\n");
+
     bool result = true;
-     int rc = 0;
-#if 1    
+
     EthernetInterface eth;
 #ifndef __CC_ARM 
 #ifdef __GNUC__
     printf("sbrk=%x:\r\n", (unsigned int)_sbrk(0));
 #endif
 #endif 
-    printf(" 300 \r\n");
-#ifndef DEMO_STATIC_IP    
-    eth.connect(); //eth.init(); //Use DHCP
-#else
-    ; //rc = eth.init(STATIC_IP, STATIC_MASK, DEFAULT_GATEWAY); 
-#endif
-    printf(" 400 \r\n");
-    if (rc != 0) {
-        printf("EthernetInterface::init() fails: %d\n", rc);
-        return -1;
-    }    
+
+
+    eth.connect(); //Use DHCP
         
     printf("TCP client IP Address is %s\r\n", eth.get_ip_address());
 
     TCPSocket sock(&eth);
-    printf(" 500 \r\n");
+   
     if (sock.connect(HTTP_SERVER_NAME, HTTP_SERVER_PORT) == 0) {
         printf("HTTP: Connected to %s:%d\r\n", HTTP_SERVER_NAME, HTTP_SERVER_PORT);
 
@@ -122,7 +106,7 @@
         printf("HTTP: Received massage:\r\n\r\n");
         printf("%s", buffer);
     }
-    printf(" 600 \r\n");
+ 
 #ifndef __CC_ARM 
 #ifdef __GNUC__
     printf("sbrk=%x:\r\n", (unsigned int)_sbrk(0));
@@ -131,5 +115,4 @@
     sock.close();
     eth.disconnect();
 //    GREENTEA_TESTSUITE_RESULT(result);
-#endif
 }