test _oliver

Dependencies:   libmDot-mbed5

Revision:
4:0fd5e5e121ea
Parent:
3:ac5101a47080
--- a/main.cpp	Tue Jan 03 17:25:01 2017 +0000
+++ b/main.cpp	Wed Jan 04 13:45:49 2017 +0000
@@ -57,6 +57,18 @@
 static bool send_data(void) {
     int32_t ret;
 
+    // check join state, @todo: add a timeout here, join is very expensive on the battery...
+    if (!dot->getNetworkJoinStatus()) {
+        logInfo("trying to send before joining, retry join...");
+        if ((ret = dot->joinNetwork()) != mDot::MDOT_OK ) {
+            logError("failed to join network %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
+            return false;
+        }
+        else {
+            logInfo("joined network successfully");
+        }
+    }
+
     std::vector<uint8_t> data;
     data.push_back(counter >> 8 & 0xff);
     data.push_back(counter & 0xff);
@@ -205,9 +217,10 @@
     logInfo("joining network");
     if ((ret = dot->joinNetwork()) != mDot::MDOT_OK ) {
         logError("failed to join network %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
-        return false;
     }
-    logInfo("joined network successfully");
+    else {
+        logInfo("joined network successfully");
+    }
 
     //*******************************************
     // end of configuration