Sensos Module Updated
Fork of Middleware by
Diff: Threads.cpp
- Revision:
- 0:d1ff330c5128
- Child:
- 1:fd355dc296b1
diff -r 000000000000 -r d1ff330c5128 Threads.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Threads.cpp Sat Dec 05 17:43:29 2015 +0000 @@ -0,0 +1,92 @@ +/* + +Thread.cpp + +Only to improve the clarity of main .cpp +This don't have any new classes + +All the multiple task are here +for Smart Room project asked by +Gustavo Torres + +Last update by RoHe 16/11/2015 + +*/ +#include "Threads.h" + +#include "Initial.h" +#include "rtos.h" +#include "Ether.h" +#include "EthernetInterface.h" + +static void sw2_press(void) +{ + ledGREEN= !ledGREEN; + +} + +static void led_thread(void const *argument) +{ + while (true) { + if(_isConnectedServer1 == true && _isConnectedServer2 == true) { + //Color GREEN + ledRED=1;//OFF + ledBLUE=1;//OFF + ledGREEN = !ledGREEN; + } else if(_isConnectedServer1 == true && _isConnectedServer2 == false) { + //Color BLUE + ledGREEN=1;//OFF + ledRED = 1; //OFF + ledBLUE = !ledBLUE; + } else if(_isConnectedServer1 == false && _isConnectedServer2 == true) { + //Color YELLOW = RED and GREEN + ledBLUE =1; //OFF + ledRED = !ledRED; + ledGREEN = !ledGREEN; + } else if(_isConnectedServer1 == false && _isConnectedServer2 == false) { + //Color RED + ledGREEN=1;//OFF + ledBLUE =1; //OFF + ledRED = !ledRED; + } + Thread::wait(1000); + } +} + +/* +static bool conect_Server(void) +{ + ////////////////////// Body of the funtion//////////////////////// + while (socketTCP1.connect(ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1) < 0) { + wait(0.5); + return false; + } +return true; + ////////////////////// end if the funtion//////////////////////// +} +*/ +static void receivedFromServer1(void const *argument) +{ + + while (true) { + // Receive message from server1 + 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 received1 ELSE value of lenght: '%u'\n\r",strlen(buf1)); + socketTCP1.close(); + //isConnectedServer1=false; + } + Thread::wait(500); + } + +} + + +