DSOS Sensors
Dependencies: EthernetInterface SensorsTointegrate mbed-rtos mbed
Fork of MainTaskGus by
Diff: Coments.cpp
- Revision:
- 0:5db5c980e717
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Coments.cpp Sat Dec 05 17:46:07 2015 +0000 @@ -0,0 +1,122 @@ +/* + +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 + +*/ + + +/* + + + + /* + + // 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); + + + + +//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); +*/ + +