An attempt to sleep an mDot

Dependencies:   libmDot-mbed5

Fork of mDot_helloworld_bk by Brendan Kelly

Revision:
3:706cdd7ce1b2
Parent:
2:9682d754c902
Child:
4:0c96c67d914b
--- a/main.cpp	Sat Aug 05 13:12:56 2017 +0000
+++ b/main.cpp	Wed Aug 09 00:08:08 2017 +0000
@@ -1,16 +1,21 @@
-/*************************************
- * This simple example program prints 
- * a message on the USB debug port.
- ************************************/
 
 #include "mbed.h"
+#include "mDot.h"
+#include "ChannelPlans.h"
+#include "MTSLog.h"
 
 int main() {
-    int count = 0;
-    // print the message on 3s interval
-    while (true) {
-        count++;
-        printf("Hello world! I am an mDot and I count %d\r\n", count);
-        wait(3);
-    }
+    // use AU915 plan
+    lora::ChannelPlan* plan = new lora::ChannelPlan_AU915();
+    assert(plan);
+    // get a mDot handle
+    mDot* dot = mDot::getInstance(plan);
+    assert(dot);
+    
+    // print the message 
+    logInfo("Hello world! I am an mDot");
+    
+    // go to sleep and wake up automatically sleep_time seconds later
+    uint32_t sleep_time = 5;
+    dot->sleep(sleep_time, mDot::RTC_ALARM);
 }
\ No newline at end of file