Here it is ...

Dependencies:   libxDot-mbed5 TSL2561

Fork of Dot-Examples by MultiTech

Revision:
35:b51d482e9731
Parent:
33:79e4c812d91d
Child:
36:5529d26e97e6
--- a/examples/src/ota_example.cpp~	Sun Jul 22 17:25:10 2018 +0000
+++ b/examples/src/ota_example.cpp~	Tue Jul 24 11:57:49 2018 -0400
@@ -1,5 +1,6 @@
 #include "dot_util.h"
 #include "RadioEvent.h"
+
  
 #if ACTIVE_EXAMPLE == OTA_EXAMPLE
 
@@ -49,8 +50,7 @@
   pc.printf("main started \r\n");
   // Custom event handler for automatically displaying RX data
   RadioEvent events;
-  
-  
+    
   
   
   mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
@@ -74,7 +74,7 @@
   
   dot = mDot::getInstance(plan);
   assert(dot);
-  pc.printf("mdot instance asserted \r\n");
+
 
   // attach the custom events handler
   dot->setEvents(&events);
@@ -86,6 +86,9 @@
     logInfo("defaulting Dot configuration");
     dot->resetConfig();
     dot->resetNetworkSession();
+
+    // set the data_rate
+    dot->setTxDataRate(lora::DR_1);
     
     // make sure library logging is turned on
     dot->setLogLevel(mts::MTSLog::INFO_LEVEL);
@@ -135,25 +138,30 @@
   }
   
   uint8_t counter = 0;
+  std::vector<uint8_t> tx_data;
+  char buffer[5];
+
   while (true) {
-    pc.printf("top of loop\r\n");
-    std::vector<uint8_t> tx_data;
-    pc.printf("we got tx_data again\r\n");
     
     // join network if not joined
     if (!dot->getNetworkJoinStatus()) {
-      pc.printf("joining\r\n");
+      pc.printf("joining lora network.\r\n");
       join_network(&pc);
-      pc.printf("post join\r\n");
     } 
     
     // hourly loop
     while( counter < 12) {
+
       uint8_t light_data = get_light_data();
-      tx_data.push_back(light_data);
       pc.printf("pseudo-light data: %d\r\n", light_data);
       pc.printf("hour: %d\r\n", ++counter);
-        
+      
+      //tx_data.push_back('M');
+      sprintf(buffer, "%d", light_data);
+      pc.printf("char buffer: %s\r\n", buffer);
+      tx_data.push_back(*buffer);
+      tx_data.push_back(' ');
+
       // 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
       if (deep_sleep) {
@@ -164,24 +172,23 @@
       // ONLY ONE of the three functions below should be uncommented depending on the desired wakeup method
       //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);
+      //sleep_wake_rtc_or_interrupt(deep_sleep);
     }
 
     //print vector data
-    pc.printf(" vector data:");
+    pc.printf("vector data:");
+    
     for(std::vector<uint8_t>::const_iterator iter = tx_data.begin(); iter != tx_data.end(); ++iter) {
-      pc.printf(" %d",*iter);
+      pc.printf(" %c",*iter);
     }
     pc.printf("\r\n");
+
+    pc.printf("size of tx_data: %d\r\n", sizeof(tx_data));
     //actually send the data
-    logInfo("sending uplink with data = %d", counter);
     pc.printf("sending data\r\n");
-    send_data(tx_data);
-    pc.printf("data sent\r\n");
+    send_data(tx_data, &pc);
 
-
-    // erase vector data
+    // erase vector data & reset counter
     tx_data.erase(tx_data.begin(), tx_data.end());
     counter = 0;
     pc.printf("deleted tx_data and reset counter\r\n");