Nathanaël Semhoun / Mbed OS mdot_commonsense

Dependencies:   libmDot-mbed5

Files at this revision

API Documentation at this revision

Comitter:
vm2m
Date:
Fri Feb 26 12:00:30 2016 +0000
Parent:
9:d5777c4e4a44
Child:
11:a87d08f4f688
Commit message:
Separate timer for sensors and reading

Changed in this revision

LoRa.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/LoRa.cpp	Thu Feb 25 17:13:24 2016 +0000
+++ b/LoRa.cpp	Fri Feb 26 12:00:30 2016 +0000
@@ -29,7 +29,8 @@
     }
     else {
         mthis->_send("");
-    }}
+    }
+}
 
 bool LoRa::init(LoRaConfig_t p_loraConfig)
 {
--- a/main.cpp	Thu Feb 25 17:13:24 2016 +0000
+++ b/main.cpp	Fri Feb 26 12:00:30 2016 +0000
@@ -142,7 +142,7 @@
     strcat(packet, data);
 }
 
-void checkSensors() {
+void SensorsTimerCb(void const*) {
     // Check sensors value
     // 1 if motion change, switch on the switch
     if (!sensorsVal.motion && sensors->getMotion()) {
@@ -199,10 +199,8 @@
     }
 }
 
-void MainTimerCb(void const*)
+void ReadTimerCb(void const*)
 {
-    checkSensors();
-    
     std::string data = lora->receive();
     if (data == "") {
         return; // <==
@@ -257,8 +255,11 @@
  
     lora->send("0 CONNECTED PROTO 2\n");
  
-    RtosTimer MainTimer(MainTimerCb, osTimerPeriodic, (void*)NULL);
-    MainTimer.start(5000);
+    RtosTimer SensorsTimer(SensorsTimerCb, osTimerPeriodic, (void*)NULL);
+    SensorsTimer.start(5000);
+    
+    RtosTimer ReadTimer(ReadTimerCb, osTimerPeriodic, (void*)NULL);
+    ReadTimer.start(500);
  
     Thread::wait(osWaitForever);
 }