DSOS Sensors

Dependencies:   EthernetInterface SensorsTointegrate mbed-rtos mbed

Fork of MainTaskGus by Roberto Herrera

Revision:
1:f3619e6e9e89
Parent:
0:5db5c980e717
diff -r 5db5c980e717 -r f3619e6e9e89 main.cpp
--- a/main.cpp	Sat Dec 05 17:46:07 2015 +0000
+++ b/main.cpp	Mon Dec 07 01:52:10 2015 +0000
@@ -9,15 +9,16 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
 #include "rtos.h"
-#include "SensorPIR.h"
+#include "Sensors.h"
 #include "Ether.h"
 #include "Initial.h"
 #include "Threads.cpp"
 #include "StringManager.h"
 
-
 int main()
 {
+    
+    
     /*////////////////////////////////////
     Initialization of the outports
 
@@ -41,31 +42,31 @@
     Declares all necessary CLASSES
     */
     
-    EthernetInterface eth;
+    /*EthernetInterface eth;
     eth.init(); //Use DHCP
-    eth.connect();
+    eth.connect();*/
 
 
     /*///////////////////////////////////
     Declares all necessary THREADS
     */
-    Thread thread1(led_thread);
-    //Thread thread2(receivedFromServer1);
+    /*Thread thread1(led_thread);
+    Thread thread2(messsageFromClient);*/
 
     /*////////////////////////////////////
     Declares all necessary INTERRUPTIONS
     */
-    sw2.fall(&sw2_press);
+    /*sw2.fall(&sw2_press);*/
 
 //////////////////////////////////////////////////////APPLICATION /////////////////////////////////////////////////////////
     
     
-    s_myIP = eth.getIPAddress();
+    /*s_myIP = eth.getIPAddress();
     pc.printf("\nClient IP Address is %s\r", s_myIP);
     pc.printf("\nClient IP MAC address is %s\r", eth.getMACAddress);
     pc.printf("\nClient IP Gateway is %s\r", eth.getGateway());
     pc.printf("\nClient IP network mask is %s\n\r", eth.getNetworkMask());
-    /*
+    
     CONSTRAINS:
     -No se puede poner un serial print el los threads ....
     -se tiene que abrir y cerrar las conecciones par que pueda leer nuevos mensajes
@@ -86,7 +87,9 @@
 
 
     while(true) {
-      
+        
+        
+        
         // Connect to Server1
         //TODO: try to connect to both servers
         //TODO: only try 5 times after ti server1 goes down
@@ -99,94 +102,9 @@
         //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;
-                }
-        //
     }// END while
-    eth.disconnect();
+    //eth.disconnect();