Updated Sensors Module. Added person counter.

Dependencies:   EthernetInterface HC_SR04_Ultrasonic_Library Middleware mbed-rtos mbed

Fork of SmartLabProyect by Jorge Martin Beltran Avila

Revision:
2:c8a2aa07cfdd
Parent:
1:106e93f9c7c8
Child:
3:4f60a40516dd
--- a/Coments.cpp	Wed Dec 09 04:45:01 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
-
-TODO:
-
-1.- Conectar a ambos servidores
-    1.1 - si no solo conectar a uno y tener present la conección activa
-2.-hacer funciones para dvidir las cadenas de los mensajes
-3.-hace funcion para formar cadenas para enviar mensajes
-4. Formato de mensajes para que los pueda leer el server
-
-*/
-
-
-/*
-
-        // Connect to Server1
-        //TODO: try to connect to both servers
-        //TODO: only try 5 times after ti server1 goes down
-        //TODO: cual es la diferencia entre recieved_all y recieved
-        //TOTRY: que valor regresa cuando hace el connect???
-
-        //QUESTION: que son los numero que aparecen despues de los dos puntos,
-        //parece ser uqe es el numero que noceciones que lleva acabo 192.168.1.81:49160
-        //NOSIRVE: si se conecta los dos micros  con el programa de TCP Server4 y se les pide un reply
-        //los micros no contestan y para terminarla si pides dos veces un reply se queda colgado ..
-        //ACCOMPLISH: los colores de los leds ya responen de acuerdo a la conexion
-
-        //GetPersonStatus(1);
-
-        for(int i=0,isConServer1=0; i<2 && isConServer1==0; i++) {
-            if(socketTCP1.connect(ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1) == -1) {
-                _isConnectedServer1=false;
-                pc.printf("Unable to connect1 to (%s) on port (%d)\n\r", ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1);
-                pc.printf("TRY SERVER 1 number (%d)\n\r",(i+1));
-                isConServer1=0;
-            } else {
-                _isConnectedServer1=socketTCP1.is_connected();
-                pc.printf("Ya se conecto con el servidor 1\n\r");
-                isConServer1=1;
-                wait(1);
-
-                char hello[] = "Hello World\n\r";
-                printf("Sending  message to Server : '%s' \n",hello);
-                socketTCP1.send_all(hello, sizeof(hello) - 1);
-
-
-
-
-            }
-        }//END FOR1
-
-                for(int i=0,isConServer2=0; i<2 && isConServer2==0; i++) {
-                    if(socketTCP2.connect(ECHO_SERVER_ADDRESS2, ECHO_SERVER_PORT2) == -1) {
-                        _isConnectedServer2=false;
-                        pc.printf("Unable to connect2 to (%s) on port (%d)\n\r", ECHO_SERVER_ADDRESS2, ECHO_SERVER_PORT2);
-                        pc.printf("TRY SERVER 2 number (%d)\n\r",(i+1));
-                        isConServer2=0;
-                        //wait(1);
-                    } else {
-                        _isConnectedServer2=socketTCP2.is_connected();
-                        pc.printf("Ya se conecto con el servidor 2\n\r");
-                        isConServer2=1;
-                    }
-                }//END FOR2
-
-
-        //RECEIVED from TCP SERVER1
-        n1 = socketTCP1.receive_all(buf1, 256);
-        buf1[n1] = '\0';
-        if(n1>0) {
-            pc.printf("Received message from server1 IF: '%s'\n\r", buf1);
-             socketTCP1.close();
-
-        } else {
-            //_isConnectedServer1==false; //quiere decir que se desconecto del servidor
-            pc.printf("Not received1 ELSE value of lenght: '%u'\n\r",strlen(buf1));
-            socketTCP1.close();
-            //isConnectedServer1=false;
-        }
-        //socketTCP1.close();
-        //socketTCP2.close();
-
-        if(strcmp(buf1,"reply")==0) {
-            // SEND to server1
-            //Entra pero no puede mandar los datos
-            // pc.printf("Entro a la funcion strcmp: \n\r");
-            if(socketTCP1.connect(ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1) == -1) {
-                pc.printf("Unable to connect1 to (%s) on port (%d)\n\r", ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1);
-                }
-
-            char c_myIP[] = "192.168.1.77\n\r";
-            pc.printf("Sending  message to Server : %s \n\r",c_myIP);
-            socketTCP1.send_all(c_myIP, sizeof(c_myIP) - 1);
-            socketTCP1.close();
-        }
-        //socketTCP1.close();
-
-
-
-                //RECEIVED from TCP SERVER2
-                n2 = socketTCP2.receive(buf2, 256);
-                buf2[n2] = '\0';
-                if(n2>0) {
-                    pc.printf("Received message from server2 IF: '%s'\n\r", buf2);
-                    socketTCP2.close();
-                    //isConnectedServer1=false;
-                } else {
-                    //_isConnectedServer1==false; //quiere decir que se desconecto del servidor
-                    pc.printf("Not received2 ELSE value of lenght: '%u'\n\r",strlen(buf2));
-                    socketTCP2.close();
-                    //isConnectedServer1=false;
-                }
-        //
-
-
-*/
-
-
-
-/*
-
-        // Receive message from server
-    char buf1[256];
-    int n1 = socketTCP1.receive(buf1, 256);
-    buf1[n1] = '\0';
-
-    if(n1>0) {
-        pc.printf("Received message from server1 IF: '%s'\n\r", buf1);
-        socketTCP1.close();
-        //isConnectedServer1=false;
-    } else {
-        //_isConnectedServer1==false; //quiere decir que se desconecto del servidor
-        pc.printf("Not received ELSE value of lenght: '%u'\n\r",strlen(buf1));
-        socketTCP1.close();
-        //isConnectedServer1=false;
-    }
-
-        if(bo_somethingWrong==true) {
-            return 0;
-        }
-
-//if(socketTCP.connect(ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1) == -1 && _isConnectedServer1==false ) {
-    if(socketTCP.connect(ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1) == -1) {
-    _isConnectedServer1=socketTCP.is_connected();
-   //_isConnectedServer1=false;
-    pc.printf("Unable to connect to (%s) on port (%d)\n\r", ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1);
-    wait(1);
-} else {
-    _isConnectedServer1=socketTCP.is_connected();
-   //_isConnectedServer1=true;
-    //pc.printf("Connected to Server at %s\n\r",ECHO_SERVER_ADDRESS1);
-    pc.printf("Connected to Server at %s\n\r",socketTCP.get_address());
-    pc.printf("Connected to PORT at %u\n\r",socketTCP.get_port());
-
-
-
-    //TODO: split strings
-
-    char hello[] = "reply:get:status:192.168.1.77:door:1\n\r";
-
-    pc.printf("Sending  message to Server : %s \n\r",hello);
-    socketTCP.send_all(hello, sizeof(hello)- 1);
-
-
-
-// Receive message from server
-    char buf[256];
-    int n = socketTCP.receive(buf, 256);
-    buf[n] = '\0';
-    pc.printf("Received message from server: '%s'\n\r", buf);
-
-            if(bo_somethingWrong==true) {
-                return 0;
-            }
-
-
-}
-
-
-
-}
-
-// Clean up
-socketTCP1.close();
-socketTCP2.close();
-*/
-
-
-
-// Send message to server
-/*
-strcat(s_myIP,"\n\r");
-pc.printf("Sending  message to Server : %s \n\r",s_myIP);
-socketTCP.send_all(s_myIP, sizeof(s_myIP) - 1);
-*/
-/*
-c_myIP = "192.168.1.77\n\r";
-//strcat(c_myIP,"\n\r");
-pc.printf("Sending  message to Server : %s \n\r",c_myIP);
-socketTCP.send_all(c_myIP, sizeof(c_myIP) - 1);
-*/
-
-//char hello[] = "reply:get:";
-//char hello2[] = "status:192.168.1.77:door:1\n\r" ;
-//strcat(hello,hello2);
-
-
-//THREADS CSDECLARATION
-//Thread thread2(conect_Server);
-//Thread *thread2;
-//thread2 = new Thread(conect_Server);
-
-/*
-// Echo received message back to client
-pc.printf("bufferReply: '%s'\n\r",bufferReply);
-//Todas las cadenas que son enviadas tienen el final de \r\n
-int lengBuffer = stringManager.stringLenght(bufferReply);
-pc.printf("longhtBuffer: '%u'\n\r",strlen(buffer));
-pc.printf("longhtBuffer n : '%u'\n\r",n);
-pc.printf("longhtBufferReply: '%u'\n\r",lengBuffer);
-pc.printf("strcmp: '%u'\n\r",strcmp(buffer,"set\r\n"));
-*/
-
-
-//IMPORT FROM LIBRARY
-/*
-cad = driver.echo();
-pc.printf("libraryECHO: %s\n\r",cad);
-int var = driver.is_good();
-pc.printf("libraryVAR: %u\n\r",var);
-*/
-
-