M3 Board Socket Communication

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of TCPEchoServer by Mbed

Files at this revision

API Documentation at this revision

Comitter:
bulmecisco
Date:
Thu Jun 16 16:51:46 2016 +0000
Parent:
7:a5ead1402704
Commit message:
M3 Board Socket Communication

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.lib	Mon May 04 22:47:02 2015 +0000
+++ b/EthernetInterface.lib	Thu Jun 16 16:51:46 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#2fc406e2553f
+https://developer.mbed.org/users/bulmecisco/code/EthernetInterface/#f42b26560a20
--- a/main.cpp	Mon May 04 22:47:02 2015 +0000
+++ b/main.cpp	Thu Jun 16 16:51:46 2016 +0000
@@ -1,7 +1,10 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
+#include "string.h"
 
-#define ECHO_SERVER_PORT   7
+DigitalOut led1(LED1);
+
+#define ECHO_SERVER_PORT   9050
 
 int main (void) {
     EthernetInterface eth;
@@ -17,7 +20,7 @@
         printf("\nWait for new connection...\n");
         TCPSocketConnection client;
         server.accept(client);
-        client.set_blocking(false, 1500); // Timeout after (1.5)s
+        //client.set_blocking(false, 1500); // Timeout after (1.5)s
         
         printf("Connection from: %s\n", client.get_address());
         char buffer[256];
@@ -29,16 +32,21 @@
             buffer[n] = '\0';
             printf("Received message from Client :'%s'\n",buffer);
             
+            if(strstr(buffer, "On1"))
+                led1 = 1;
+            if(strstr(buffer, "Off1"))
+                led1 = 0;
+            
             // reverse the message
-            char temp;
+            /*char temp;
             for(int f = 0, l = n-1; f<l; f++,l--){
                 temp = buffer[f];
                 buffer[f] = buffer[l];
                 buffer[l] = temp;
                 }
-            
+            */
             // print reversed message to terminal
-            printf("Sending message to Client: '%s'\n",buffer);
+            printf("Sending message to Client: '%s'\n","OK");
             
             // Echo received message back to client
             client.send_all(buffer, n);
--- a/mbed-rtos.lib	Mon May 04 22:47:02 2015 +0000
+++ b/mbed-rtos.lib	Thu Jun 16 16:51:46 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#557d5b275f31
+http://mbed.org/users/mbed_official/code/mbed-rtos/#4c105b8d7cae