no description
Fork of Middleware by
Threads.cpp
- Committer:
- RoHe
- Date:
- 2015-12-05
- Revision:
- 0:d1ff330c5128
- Child:
- 1:32a08ca33b00
File content as of revision 0:d1ff330c5128:
/* 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); } }