Windshape control / Mbed OS Controle_ventilo_ethernet_v1_2_4

Fork of Controle_ventilo_ethernet_v1_2_4 by Sergio Márquez

Revision:
5:cee119979b55
Parent:
4:fb63da7601aa
Child:
6:6567daa93121
--- a/main.cpp	Fri Apr 21 17:30:06 2017 +0000
+++ b/main.cpp	Wed May 17 15:36:31 2017 +0000
@@ -2,8 +2,6 @@
 #include "EthernetInterface.h"
 #include "Ethernet.h"
 
-#include "TCPSocket.h"
-
 #include "SocketAddress.h"
 #include "Socket.h"
 #include "UDPSocket.h"
@@ -11,7 +9,7 @@
 #include <string.h> 
 //using namespace std;
 
-const char* ECHO_SERVER_ADDRESS = "192.168.137.1";    // addresse du PC home "192.168.1.2" sergio "169.254.61.104" or "129.194.185.33" or "192.168.137.1" liotard "10.136.134.73"
+const char* ECHO_SERVER_ADDRESS = "131.215.118.148";    // addresse du PC home "192.168.1.2" sergio "169.254.61.104" or "129.194.185.33" or "192.168.137.1" liotard "10.136.134.73"
 //#define IP "10.136.134.100"
 //#define GATEWAY "10.136.132.1"         //"129.194.184.1"
 //#define MASK "255.255.252.0"
@@ -40,6 +38,7 @@
 int pwm_len = 0;
 
 void splitString(char stringToSplit[]);
+int transString(char stringToTrans[]);
 
 int main(int argc, char *argv[]) {
     
@@ -62,7 +61,10 @@
     
     //eth.set_network(IP,MASK,GATEWAY);
     
-    printf("\nClient IP Address is %s \n", eth.get_ip_address());
+    const char *local_ip = eth.get_ip_address();
+    const char *local_mac = eth.get_mac_address();
+    
+    printf("\nClient IP Address is %s \n", local_ip);
     
     echo_server.set_ip_address(ECHO_SERVER_ADDRESS);
     echo_server.set_port(ECHO_SERVER_PORT);
@@ -76,11 +78,11 @@
     //wait(10);
     
     while(ack == 0){
-        char out_buffer[256];
+        char out_buffer[18];
         snprintf(out_buffer, sizeof(out_buffer), "%s", eth.get_mac_address());
         sock.sendto(echo_server, out_buffer, sizeof(out_buffer));
         
-        //printf("%s\n", out_buffer);
+        printf("%s\n", out_buffer);
         
         sock.set_timeout(1000);
         
@@ -90,7 +92,9 @@
         
         printf("%s\n", in_buffer);
         
-        if(in_buffer == "got you"){
+        int ack_message = transString(in_buffer);
+        
+        if(ack_message == 1){
             ack = 1;
             sock.set_timeout(-1);
             }
@@ -168,4 +172,11 @@
     strncpy(pwm_str, comma_2, pwm_len);
     int pwm = atoi(pwm_str);
     pwm_f = (float)pwm/100.0;
-}
\ No newline at end of file
+}
+
+int transString(char stringToTrans[]){
+    char in_str[2] = {0};
+    strncpy(in_str, stringToTrans,1);
+    int in = atoi(in_str);
+    return in;
+    }
\ No newline at end of file