Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 10:4161559755d2, committed 2016-02-26
- 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);
}