Here it is ...

Dependencies:   libxDot-mbed5 TSL2561

Fork of Dot-Examples by MultiTech

Revision:
32:cc05a2e80969
Parent:
31:b990f61b9ee0
Child:
33:79e4c812d91d
--- a/examples/src/ota_example.cpp	Wed Jul 11 13:40:54 2018 -0400
+++ b/examples/src/ota_example.cpp	Thu Jul 12 12:54:47 2018 -0400
@@ -28,7 +28,7 @@
 static uint8_t network_key[] = { 0x1F, 0x33, 0xA1, 0x70, 0xA5, 0xF1, 0xFD, 0xA0, 0xAB, 0x69, 0x7A, 0xAE, 0x2B, 0x95, 0x91, 0x6B };
 static uint8_t frequency_sub_band = 1;
 static lora::NetworkType public_network;// = lora::PUBLIC_LORAWAN;
-static uint8_t join_delay = 5;
+static uint8_t join_delay = 1;
 static uint8_t ack = 0;
 static bool adr = true;
 
@@ -52,7 +52,6 @@
   
   
   
-  pc.printf("baud rate set \r\n");
   
   mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
   
@@ -75,7 +74,8 @@
   
   dot = mDot::getInstance(plan);
   assert(dot);
-  
+  pc.printf("mdot instance asserted \r\n");
+
   // attach the custom events handler
   dot->setEvents(&events);
   
@@ -101,8 +101,8 @@
     // only one method or the other should be used!
     // network ID = crc64(network name)
     // network KEY = cmac(network passphrase)
-    //update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, public_network, ack);// use the line below
-    update_ota_config_id_key(network_id, network_key, frequency_sub_band, public_network, ack); ///
+    update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, public_network, ack);
+    //update_ota_config_id_key(network_id, network_key, frequency_sub_band, public_network, ack); 
     
     // configure network link checks
     // network link checks are a good alternative to requiring the gateway to ACK every packet and should allow a single gateway to handle more Dots
@@ -117,6 +117,8 @@
     // Configure the join delay
     dot->setJoinDelay(join_delay);
     
+    pc.printf("network information set\r\n");
+
     // save changes to configuration
     logInfo("saving configuration");
     if (!dot->saveConfig()) {
@@ -134,16 +136,24 @@
   
   uint8_t counter = 0;
   while (true) {
+    pc.printf("starting network join process\r\n");
+
     std::vector<uint8_t> tx_data;
     
     // join network if not joined
     if (!dot->getNetworkJoinStatus()) {
-      join_network();
+      pc.printf("joining\r\n");
+      join_network(&pc);
+      pc.printf("post join\r\n");
+    } else {
+          pc.printf("Network has been joined\r\n");
     }
     
     tx_data.push_back(++counter);
     logInfo("sending uplink with data = %d", counter);
+    pc.printf("sending data\r\n");
     send_data(tx_data);
+    pc.printf("data send\r\n");
     
     // if going into deepsleep mode, save the session so we don't need to join again after waking up
     // not necessary if going into sleep mode since RAM is retained
@@ -156,6 +166,7 @@
     //sleep_wake_rtc_only(deep_sleep);
     //sleep_wake_interrupt_only(deep_sleep);
     sleep_wake_rtc_or_interrupt(deep_sleep);
+    pc.printf("end of loop %d \r\n", counter);
   }
   
   return 0;