A simple LoRaWAN temperature sensor based on Multitech mDot module.

Dependencies:   DS1820 libmDot mbed-rtos mbed

Revision:
5:dd77f0401170
Parent:
4:f649ab1b61d1
Child:
6:9b53147a345f
--- a/main.cpp	Thu Oct 15 20:34:52 2015 +0000
+++ b/main.cpp	Wed Nov 18 21:07:12 2015 +0000
@@ -31,6 +31,7 @@
 // /var/config/lora/lora-network-server.conf
 static std::string config_network_name = "ThingInnovations";
 static std::string config_network_pass = "donkey123";
+
 // Ignoring sub band for EU modules.
 //static uint8_t config_frequency_sub_band = 1;
 
@@ -69,7 +70,7 @@
     configReset.mode(PullUp);
 
     pc.baud(115200);
-    pc.printf("mDot LoRa Temperature sensor\n\r");
+    pc.printf("Private LoRaWAN Temperature sensor\n\r");
 
     // get a mDot handle
     dot = mDot::getInstance();
@@ -81,6 +82,8 @@
 
     // Test if we've already saved the config
     std::string configNetworkName = dot->getNetworkName();
+    
+    pc.printf("Name: %s\r\n",config_network_name.c_str());
 
     // Reset config if network name is different or pin is low then reset config.
     if( config_network_name.compare(configNetworkName) != 0 || !configReset ) {
@@ -90,10 +93,11 @@
         // reset to default config so we know what state we're in
         dot->resetConfig();
 
-        // Set byte order - AEP less than 1.0.30
-//    dot->setJoinByteOrder(mDot::MSB);
-        dot->setJoinByteOrder(mDot::LSB);
+        // Set byte order - AEP less than 1.0.30 needs LSB
+//        dot->setJoinByteOrder(mDot::LSB);
+        dot->setJoinByteOrder(mDot::MSB);       // This is default for > 1.0.30 Conduit
 
+        dot->setPublicNetwork(true);
         logInfo("setting Join mode");
         if ((ret = dot->setJoinMode(mDot::AUTO_OTA)) != mDot::MDOT_OK) {
             logError("failed to set Join Mode %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
@@ -128,10 +132,6 @@
             logError("failed to set network password %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
         }
 
-        if ((ret = dot->setJoinMode( mDot::AUTO_OTA )) != mDot::MDOT_OK) {
-            logError("failed to set join mode %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
-        }
-
         logInfo("Saving Config");
 
         // Save config
@@ -141,7 +141,7 @@
     } else {
         logInfo("Using existing Config");
     }
-
+ 
     logInfo("Joining Network");
 
     while ((ret = dot->joinNetwork()) != mDot::MDOT_OK) {
@@ -180,6 +180,7 @@
         // go to sleep and wake up automatically sleep_time seconds later
         dot->sleep(sleep_time, mDot::RTC_ALARM);
 
+//        wait_ms(sleep_time * 1000);
     }
 
     return 0;