My experiments with the W7500 TCP Client

Dependencies:   WIZnetInterface mbed

Fork of TCPEchoServer-WIZwiki-W7500 by WIZnet

Files at this revision

API Documentation at this revision

Comitter:
ipv1
Date:
Wed Apr 06 08:11:01 2016 +0000
Parent:
11:0da8667a9201
Commit message:
Dummy but working text as well as commands

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0da8667a9201 -r 30006dcdb92d main.cpp
--- a/main.cpp	Mon Jun 29 09:46:12 2015 +0000
+++ b/main.cpp	Wed Apr 06 08:11:01 2016 +0000
@@ -3,12 +3,18 @@
 
 #define ECHO_SERVER_PORT   7
 
+
 int main (void) 
 {
+    DigitalOut myled(LED1);
     printf("Wait a second...\r\n");
     uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02}; 
+    static const char*          mbedIp       = "192.168.64.232";  //IP
+    static const char*          mbedMask     = "255.255.255.0";  // Mask
+    static const char*          mbedGateway  = "192.168.64.1";    //Gateway
+ 
     EthernetInterface eth;
-    eth.init(mac_addr); //Use DHCP
+    eth.init(mac_addr, mbedIp, mbedMask, mbedGateway); //Use DHCP
     eth.connect();
     printf("Server IP Address is %s\r\n", eth.getIPAddress());
     
@@ -29,18 +35,23 @@
             int n = client.receive(buffer, sizeof(buffer));
             if (n <= 0) break;
             
+            if(buffer[0]=='Y'){
+                myled=1;
+            }else{
+                myled=0;
+            }
             // print received message to terminal
-            buffer[n] = '\0';
-            printf("Received message from Client :'%s'\r\n",buffer);
+            //buffer[n] = '\0';
+            //printf("Received message from Client :'%s'\r\n",buffer);
             
             // reverse the message
-            char temp;
-            for(int f = 0, l = n-1; f<l; f++,l--){
-                temp = buffer[f];
-                buffer[f] = buffer[l];
-                buffer[l] = temp;
-                }
-            
+            //char temp;
+//            for(int f = 0, l = n-1; f<l; f++,l--){
+//                temp = buffer[f];
+//                buffer[f] = buffer[l];
+//                buffer[l] = temp;
+//                }
+            sprintf(buffer, "Hi Alisha.How are u?");
             // print reversed message to terminal
             printf("Sending message to Client: '%s'\r\n",buffer);