Here it is ...

Dependencies:   libxDot-mbed5 TSL2561

Fork of Dot-Examples by MultiTech

Files at this revision

API Documentation at this revision

Comitter:
David Gutsch dgutsch@umail.iu.edu
Date:
Mon Jul 30 08:51:08 2018 -0400
Parent:
39:0d4362063352
Commit message:
refactored for boy scout demo. Gain is being set to high (16x) too.

Changed in this revision

examples/src/ota_example.cpp Show annotated file Show diff for this revision Revisions of this file
examples/src/ota_example.cpp~ Show annotated file Show diff for this revision Revisions of this file
--- a/examples/src/ota_example.cpp	Thu Jul 26 12:03:47 2018 -0400
+++ b/examples/src/ota_example.cpp	Mon Jul 30 08:51:08 2018 -0400
@@ -26,12 +26,12 @@
 /////////////////////////////////////////////////////////////
 
 // wifi gateway
-//static std::string network_name = "MTCDT-19400691";
-//static std::string network_passphrase = "MTCDT-19400691";
+static std::string network_name = "MTCDT-19400691";
+static std::string network_passphrase = "MTCDT-19400691";
 
 // cellular gateway
-static std::string network_name = "iuiot-gw1";
-static std::string network_passphrase = "pivotiot";
+//static std::string network_name = "iuiot-gw1";
+//static std::string network_passphrase = "pivotiot";
 
 
 static uint8_t network_id[] = { 0x6C, 0x4E, 0xEF, 0x66, 0xF4, 0x79, 0x86, 0xA6 };
@@ -47,7 +47,7 @@
 // in deepsleep mode, IOs float, RAM is lost, and application will start from beginning after waking up
 // if deep_sleep == true, device will enter deepsleep mode
 static bool deep_sleep = false;
-static const uint16_t HOURLY_SLEEP_INTERVAL = 3600; // 1 hour 
+static const uint16_t HOURLY_SLEEP_INTERVAL = 5; // 1 hour      *** changed for demo 1 min
 static const uint16_t DAILY_SLEEP_INTERVAL = 43200; // 12 hours
 
 mDot* dot = NULL;
@@ -74,6 +74,8 @@
     wait(1);
   }
 
+  // set gain on light sensor
+  lightSensor.set_timing_reg(TIMING_GAIN_16);
 
   
   mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
@@ -230,8 +232,8 @@
     counter = 0;
     pc.printf("deleted tx_data and reset counter\r\ncap: %d size: %d\r\n", tx_data.capacity(), tx_data.size());
 
-    // sleep for the day
-    sleep_wake_rtc_only(deep_sleep, DAILY_SLEEP_INTERVAL, &pc);
+    // sleep for the day  *** don't want to sleep for 12 hours for the demo
+    //sleep_wake_rtc_only(deep_sleep, DAILY_SLEEP_INTERVAL, &pc);
     
   }
   
--- a/examples/src/ota_example.cpp~	Thu Jul 26 12:03:47 2018 -0400
+++ b/examples/src/ota_example.cpp~	Mon Jul 30 08:51:08 2018 -0400
@@ -1,6 +1,7 @@
 #include "dot_util.h"
 #include "RadioEvent.h"
 #include "TSL2561.h"
+
  
 #if ACTIVE_EXAMPLE == OTA_EXAMPLE
 
@@ -23,8 +24,16 @@
 // * either the network name and passphrase can be used or //
 //     the network ID (8 bytes) and KEY (16 bytes)         //
 /////////////////////////////////////////////////////////////
+
+// wifi gateway
 static std::string network_name = "MTCDT-19400691";
 static std::string network_passphrase = "MTCDT-19400691";
+
+// cellular gateway
+//static std::string network_name = "iuiot-gw1";
+//static std::string network_passphrase = "pivotiot";
+
+
 static uint8_t network_id[] = { 0x6C, 0x4E, 0xEF, 0x66, 0xF4, 0x79, 0x86, 0xA6 };
 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;
@@ -37,13 +46,16 @@
 // in sleep mode, IO state is maintained, RAM is retained, and application will resume after waking up
 // in deepsleep mode, IOs float, RAM is lost, and application will start from beginning after waking up
 // if deep_sleep == true, device will enter deepsleep mode
-static bool deep_sleep = true;
+static bool deep_sleep = false;
+static const uint16_t HOURLY_SLEEP_INTERVAL = 5; // 1 hour      *** changed for demo 1 min
+static const uint16_t DAILY_SLEEP_INTERVAL = 43200; // 12 hours
 
 mDot* dot = NULL;
 lora::ChannelPlan* plan = NULL;
 
-
+DigitalOut led1(LED1);
 Serial pc(PA_9, PA_10);
+TSL2561 lightSensor(PB_9, PB_8);
 
 int main() {
   pc.baud(115200);
@@ -51,7 +63,18 @@
   // Custom event handler for automatically displaying RX data
   RadioEvent events;
     
-  
+
+  /////////////////////////////
+  // visual display
+  led1 = 0;
+  for(int i = 0; i < 5; i++) {
+    led1 = 1;
+    wait(1);
+    led1 = 0;
+    wait(1);
+  }
+
+
   
   mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
   
@@ -153,7 +176,7 @@
     // hourly loop
     while( counter < 12) {
 
-      uint8_t light_data = get_light_data();
+      uint8_t light_data = get_light_data(&lightSensor, &pc);
       //pc.printf("pseudo-light data: %d\r\n", light_data);
       pc.printf("\r\nhour: %d\r\n", ++counter);
       
@@ -177,7 +200,7 @@
       }
       
       // ONLY ONE of the three functions below should be uncommented depending on the desired wakeup method
-      sleep_wake_rtc_only(deep_sleep, 30, &pc);
+      sleep_wake_rtc_only(deep_sleep, HOURLY_SLEEP_INTERVAL, &pc);
       //sleep_wake_interrupt_only(deep_sleep);
       //sleep_wake_rtc_or_interrupt(deep_sleep);
     }
@@ -191,8 +214,6 @@
     pc.printf("\r\n");
 
     pc.printf("capacity tx_data: %d\r\n", tx_data.capacity());
-    //tx_data.reserve(tx_data.size());
-    //pc.printf("cap resized: %d\r\n", tx_data.capacity());
     pc.printf("sized tx_data: %d\r\n", tx_data.size());
     //actually send the data
     pc.printf("sending data\r\n");
@@ -208,6 +229,9 @@
     tx_data.erase(tx_data.begin(), tx_data.end());
     counter = 0;
     pc.printf("deleted tx_data and reset counter\r\ncap: %d size: %d\r\n", tx_data.capacity(), tx_data.size());
+
+    // sleep for the day  *** don't want to sleep for 12 hours for the demo
+    //sleep_wake_rtc_only(deep_sleep, DAILY_SLEEP_INTERVAL, &pc);
     
   }