Smart-Home-TX Test

Dependencies:   4DGL-uLCD-SE PinDetect

Fork of Xbee-Smart-Home-Outside by prana koirala

Revision:
2:b549ccada3c3
Parent:
1:7d069ab3f551
Child:
3:80ca319bd924
diff -r 7d069ab3f551 -r b549ccada3c3 main.cpp
--- a/main.cpp	Tue Apr 25 22:37:54 2017 +0000
+++ b/main.cpp	Wed Apr 26 04:10:40 2017 +0000
@@ -20,17 +20,19 @@
 volatile bool flipLed = false;
 
 Thread t1;
-Mutex serialMutex;
+// Mutex serialMutex;
 
 char buffer[50];
 
 void statusRequest()
 {
+    led1 = 1;
     statusReq = true;
 }
 
 void flipLight()
 {
+    led2 = 1;
     flipLed = true;
 }
 
@@ -39,9 +41,8 @@
     while(xbee.writeable()) {
         led2 = 1;
         char outbuf = out;
-        serialMutex.lock();
         xbee.putc(outbuf);
-        serialMutex.unlock();
+        pc.putc(outbuf);
         led2 = 0;
     }
 }
@@ -53,16 +54,14 @@
             led1 = 1;
             int x = 0;
             while(xbee.readable()) {
-                serialMutex.lock();
                 buffer[x] = xbee.getc();
                 x++;
-                serialMutex.unlock();
             }
             led1 = 0;
             const char s[2] = "|";
             char *token;
             token = strtok(buffer, s); // get the first token 
-            int j = 1;
+            int j = 2;
             while( token != NULL ) { // walk through other tokens 
                 lcd.locate(11,j);   // Print in correct place of LCD
                 lcd.printf( "%s", token );
@@ -80,9 +79,10 @@
     wait_ms(1);
     reset = 1;
     wait_ms(1);
+    getStatus.mode(PullDown);
+    toggleLight.mode(PullDown);
     getStatus.rise(&statusRequest); //attach address of function on rising edge
     toggleLight.rise(&flipLight);
-
     // lcd.baudrate(300000);
     lcd.cls();
     lcd.locate(0,0);
@@ -98,11 +98,13 @@
 
     while(1) {
         if (statusReq == true) {
-            sendcommand('c');
+            sendcommand('s');
+            statusReq = false;
         } else if (flipLed == true) {
             sendcommand('l');
+            flipLed = false;
         }
-        Thread::wait(1000);
+        Thread::wait(2000);
 
     }
 }