PIR still blocked by the XBee reading. Audio sensor not configured yet.

Dependencies:   BME280 SI1145 mbed

Revision:
8:99788d3a0514
Parent:
7:5d217e208d3f
--- a/main.cpp	Mon Jul 31 18:56:00 2017 +0000
+++ b/main.cpp	Mon Aug 14 13:28:49 2017 +0000
@@ -42,6 +42,8 @@
 bool pir_enable = false;
 bool pir_trigger = false;
 
+Ticker reset_timer;
+
 // Declare Serial Interfaces
 Serial xb(tx, rx); // Serial 1
 Serial pc(PB_3, PB_4); // Serial 2
@@ -63,12 +65,18 @@
 
 // PIR interrupt. Set the pir_trigger to true when interrupted.
 void PIR(void){
+    /*
+    if(PIR_sensor.read()){
+        pc.printf("# \r\n");
+        pir_trigger = true;
+    }*/
     
-    //pc.printf(" %d \r\n", PIR_sensor.read());
+    
     if(PIR_sensor.read() && !pir_trigger){
         pc.printf("# \r\n");
         pir_trigger = true;
     }
+    
 }
 
 // This method is attached to a timer
@@ -88,7 +96,6 @@
     //pc.printf("%c", c);
     
     if(c == '\n'){
-        rx_index++;
         rx_flag = true;
         rx_index = 0;
         pc.printf("                                \r\n");
@@ -99,20 +106,26 @@
     
     if(rx_index > 127){
         rx_index = 0;
+    }   
+}
+
+void system_reset() {
+    NVIC_SystemReset();
     }
-    
-}
 
 int main() {
     initialize_serial_connections();
     memset(rx_buffer, '\0', 128);
     pc.printf("\n\rMic test 1-2, 1-2\n\r");
+    pc.printf("NODE ID: %c\n\r", nodeID);
     
     xb.attach(&rx_read_callback, Serial::RxIrq);
     
     // Attach the PIR function to ticker thing
-    pir_timer.attach(&PIR, 0.1);
+    pir_timer.attach(&PIR, 0.2);
     pir_send_timer.attach(&PIR_timed_send, 1.5);
+    reset_timer.attach(&system_reset, 169);
+    
      
     char pc_data = 'e';