no description

Fork of Middleware by Roberto Herrera

Files at this revision

API Documentation at this revision

Comitter:
RoHe
Date:
Sat Dec 05 17:43:29 2015 +0000
Child:
1:32a08ca33b00
Commit message:
MiddleWare GUS

Changed in this revision

Database.cpp Show annotated file Show diff for this revision Revisions of this file
Database.h Show annotated file Show diff for this revision Revisions of this file
Ether.cpp Show annotated file Show diff for this revision Revisions of this file
Ether.h Show annotated file Show diff for this revision Revisions of this file
Initial.h Show annotated file Show diff for this revision Revisions of this file
SensorPIR.cpp Show annotated file Show diff for this revision Revisions of this file
SensorPIR.h Show annotated file Show diff for this revision Revisions of this file
StringManager.cpp Show annotated file Show diff for this revision Revisions of this file
StringManager.h Show annotated file Show diff for this revision Revisions of this file
Threads.cpp Show annotated file Show diff for this revision Revisions of this file
Threads.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Database.cpp	Sat Dec 05 17:43:29 2015 +0000
@@ -0,0 +1,14 @@
+/*
+
+Database.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
+
+*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Database.h	Sat Dec 05 17:43:29 2015 +0000
@@ -0,0 +1,14 @@
+/*
+
+Database.h
+
+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
+
+*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Ether.cpp	Sat Dec 05 17:43:29 2015 +0000
@@ -0,0 +1,40 @@
+/*
+Ether.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 "Ether.h"
+
+/*
+    // Connect to Server
+    TCPSocketConnection socket;
+      while (socket.connect(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT) < 0) {
+          pc.printf("Unable to connect to (%s) on port (%d)\n\r", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
+         wait(1);
+    }
+    pc.printf("Connected to Server at %s\n\r",ECHO_SERVER_ADDRESS);
+
+    // Send message to server
+    char hello[] = "Hello World";
+    pc.printf("Sending  message to Server : '%s' \n\r",hello);
+    socket.send_all(hello, sizeof(hello) - 1);
+
+    // Receive message from server
+    char buf[256];
+    int n = socket.receive(buf, 256);
+    buf[n] = '\0';
+    pc.printf("Received message from server: '%s'\n\r", buf);
+
+    // Clean up
+    socket.close();
+    eth.disconnect();
+    */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Ether.h	Sat Dec 05 17:43:29 2015 +0000
@@ -0,0 +1,44 @@
+/*
+Ether.h
+
+Only to improve the clarity of main .cpp
+This don't have any new classes
+
+All Ehternet Aplication
+for Smart Room project asked by
+Gustavo Torres
+
+Last update by RoHe 16/11/2015
+
+*/
+
+//const char* ECHO_SERVER_ADDRESS = "192.168.74.1";
+//const int ECHO_SERVER_PORT = 7;
+
+
+
+#ifndef ETHER_H_
+#define ETHER_H_
+
+//#include "EthernetInterface.h"
+//#include "Initial.h"
+
+static const char* ECHO_SERVER_ADDRESS1= "192.168.1.83";
+static const int ECHO_SERVER_PORT1 = 7;
+static bool _isConnectedServer1= false;
+
+
+static const char* ECHO_SERVER_ADDRESS2= "192.168.1.80";
+static const int ECHO_SERVER_PORT2 = 7;
+static bool _isConnectedServer2= false;
+
+// Receive message from server1
+static char buf1[256];
+static int n1;
+
+// Receive message from server2
+static char buf2[256];
+static int n2;
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Initial.h	Sat Dec 05 17:43:29 2015 +0000
@@ -0,0 +1,37 @@
+/*
+
+Initial.h
+
+Only to improve the clarity of main .cpp
+This don't have any new classes
+
+Initial Configuration for 
+Smart Room project is here
+
+Last update by RoHe 16/11/2015
+*/
+
+#ifndef INITIAL_H_
+#define INITIAL_H_
+
+#include "mbed.h"
+#include "EthernetInterface.h"
+
+static Serial pc(USBTX, USBRX);
+static DigitalOut ledRED(LED1);
+static  DigitalOut ledGREEN(LED2);
+static DigitalOut ledBLUE(LED3);
+static DigitalIn enable1(D8);
+static InterruptIn sw2(SW2);
+static TCPSocketConnection socketTCP1;
+static TCPSocketConnection socketTCP2;
+static UDPSocket socketUDP;
+//sstatic TCPSocketConnection socket;
+static char *cad;
+static char *s_myIP;
+//static char c_myIP[256];
+static char *s_end="\n\r";
+static bool bo_somethingWrong=false;
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SensorPIR.cpp	Sat Dec 05 17:43:29 2015 +0000
@@ -0,0 +1,85 @@
+/*
+
+Drivers.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 "SensorPIR.h"
+
+Drivers::Drivers()
+{
+    varInt=5;
+}
+
+bool Drivers::is_good(void)
+{
+    return true;
+}
+
+int Drivers::getVar(void)
+{
+    return varInt;
+}
+
+char* Drivers::echo(void)
+{
+    return "Hello from Library";
+}
+ 
+/*Defines*/
+//Serial UARTPIR(USBTX, USBRX);
+//DigitalOut dout(LED1);
+//DigitalIn enable2(D1);
+//DigitalIn enable3(D2);
+//DigitalIn enable4(D3);
+ 
+/*Functions*/
+int GetPersonStatus(int RoomPrescence) {
+    bool print = 0;
+    bool RoomStatus = 0;   
+    wait(2); //Wait for sensor to take snap shot of still room
+    
+    switch(RoomPrescence)
+    {
+      case 1:
+            if(enable1==1 /*|| enable2==1 || enable3==1 || enable4==1*/)
+            {
+                RoomStatus = 1;
+                ledGREEN=1;
+                if(print == 0)
+                {
+                    pc.printf("Presencia detectada\n\r");
+                    print = 1;
+                }
+            }
+            else
+            {
+                RoomStatus = 0;
+                ledGREEN=0;
+                if(print == 1)
+                {
+                    pc.printf("Ninguna presencia detectada\n\r");
+                    print = 0;
+                }
+            }
+            break;
+            
+        case 2:
+        /*ADD NEW ROOM*/
+            break;
+            
+        default:
+        /*Do Nothing*/
+            break;
+    }
+    return RoomStatus;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SensorPIR.h	Sat Dec 05 17:43:29 2015 +0000
@@ -0,0 +1,44 @@
+/*
+
+Database.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 "mbed.h"
+#include "Initial.h"
+
+#ifndef SENSORPIR_H_
+#define SENSORPIR_H_
+
+class Drivers {
+   
+public:  
+    Drivers();    
+    bool is_good(void);
+    int getVar(void);
+    char* echo(void);
+    
+private:  
+     int varInt; 
+};
+
+
+ 
+/*Extern Defines*/
+ 
+/*Extern Variables*/
+ 
+/*Extern Functions*/
+extern int GetPersonStatus(int RoomPrescence);
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/StringManager.cpp	Sat Dec 05 17:43:29 2015 +0000
@@ -0,0 +1,13 @@
+/*
+
+StringManager.cpp
+
+Only to improve the clarity of main .cpp
+This don't have any new classes
+
+This import is use to manage the strings
+
+Last update by RoHe 16/11/2015
+*/
+
+#include <string.h>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/StringManager.h	Sat Dec 05 17:43:29 2015 +0000
@@ -0,0 +1,16 @@
+/*
+
+StringManager.h
+
+Only to improve the clarity of main .cpp
+This don't have any new classes
+
+This import is use to manage the strings
+
+Last update by RoHe 16/11/2015
+*/
+
+#include <string.h>
+
+static char * joinString(char* str1, char* str2, char* str3);
+static void splitString(char* str1); // it mus return seven strings
\ No newline at end of file
--- /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);
+    }
+
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Threads.h	Sat Dec 05 17:43:29 2015 +0000
@@ -0,0 +1,26 @@
+/*
+
+Thread.h
+
+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 "Initial.h"
+
+/*
+#ifndef THREADS_H_
+#define THREADS_H_
+ 
+  #include "Initial.h"
+  #include "rtos.h"
+  //#include "Threads.cpp"
+  
+#endif
+*/