An attempt to sleep an mDot

Dependencies:   libmDot-mbed5

Fork of mDot_helloworld_bk by Brendan Kelly

Committer:
kellybs1
Date:
Mon Aug 21 05:01:57 2017 +0000
Revision:
6:5fc728e59130
Parent:
5:4f89c0fcbe59
Working version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfiore 0:fdc94d24e54a 1
mfiore 0:fdc94d24e54a 2 #include "mbed.h"
kellybs1 3:706cdd7ce1b2 3 #include "mDot.h"
kellybs1 3:706cdd7ce1b2 4 #include "ChannelPlans.h"
kellybs1 3:706cdd7ce1b2 5 #include "MTSLog.h"
mfiore 0:fdc94d24e54a 6
kellybs1 4:0c96c67d914b 7
mfiore 0:fdc94d24e54a 8 int main() {
kellybs1 4:0c96c67d914b 9 int count = 0;
kellybs1 3:706cdd7ce1b2 10 // use AU915 plan
kellybs1 3:706cdd7ce1b2 11 lora::ChannelPlan* plan = new lora::ChannelPlan_AU915();
kellybs1 3:706cdd7ce1b2 12 assert(plan);
kellybs1 3:706cdd7ce1b2 13 // get a mDot handle
kellybs1 3:706cdd7ce1b2 14 mDot* dot = mDot::getInstance(plan);
kellybs1 3:706cdd7ce1b2 15 assert(dot);
kellybs1 3:706cdd7ce1b2 16
kellybs1 4:0c96c67d914b 17 //it will keep looping and sleeping in this loop - thread continues from sleep
kellybs1 4:0c96c67d914b 18 while (true) {
kellybs1 4:0c96c67d914b 19 count++;
kellybs1 3:706cdd7ce1b2 20 // print the message
kellybs1 4:0c96c67d914b 21 logInfo("Hello world! I am an mDot counting %d", count);
kellybs1 4:0c96c67d914b 22 // go to sleep and wake up automatically sleep_time seconds later
kellybs1 3:706cdd7ce1b2 23 uint32_t sleep_time = 5;
kellybs1 6:5fc728e59130 24 //false is "don't deep sleep" - mDot doesn't do that
kellybs1 4:0c96c67d914b 25 dot->sleep(sleep_time, mDot::RTC_ALARM, false);
kellybs1 5:4f89c0fcbe59 26 printf("\r\n\r\n");
kellybs1 4:0c96c67d914b 27 }
mfiore 0:fdc94d24e54a 28 }