Basic xdot code to check how many memory is available for user APP after initializing libxdot lorawan stack

Revision:
25:56f7775c702f
Parent:
22:d9bc10bbc433
Child:
29:9e2c0d990ace
--- a/examples/src/auto_ota_example.cpp	Tue Jul 11 10:46:17 2017 -0500
+++ b/examples/src/auto_ota_example.cpp	Wed Mar 14 14:38:08 2018 -0500
@@ -27,7 +27,8 @@
 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 = 0;
-static bool public_network = false;
+static lora::NetworkType public_network = lora::PUBLIC_LORAWAN;
+static uint8_t join_delay = 5;
 static uint8_t ack = 0;
 static bool adr = true;
 
@@ -42,13 +43,6 @@
 
 Serial pc(USBTX, USBRX);
 
-#if defined(TARGET_XDOT_L151CC)
-I2C i2c(I2C_SDA, I2C_SCL);
-ISL29011 lux(i2c);
-#else
-AnalogIn lux(XBEE_AD0);
-#endif
-
 int main() {
     // Custom event handler for automatically displaying RX data
     RadioEvent events;
@@ -115,6 +109,9 @@
 
         // enable or disable Adaptive Data Rate
         dot->setAdr(adr);
+
+        // Configure the join delay
+        dot->setJoinDelay(join_delay);
     
         // save changes to configuration
         logInfo("saving configuration");
@@ -126,8 +123,8 @@
         display_config();
     }
 
+    uint8_t counter = 0;
     while (true) {
-        uint16_t light;
         std::vector<uint8_t> tx_data;
 
         // join network if not joined
@@ -135,30 +132,10 @@
             join_network();
         }
 
-#if defined(TARGET_XDOT_L151CC)
-        // configure the ISL29011 sensor on the xDot-DK for continuous ambient light sampling, 16 bit conversion, and maximum range
-        lux.setMode(ISL29011::ALS_CONT);
-        lux.setResolution(ISL29011::ADC_16BIT);
-        lux.setRange(ISL29011::RNG_64000);
-
-        // get the latest light sample and send it to the gateway
-        light = lux.getData();
-        tx_data.push_back((light >> 8) & 0xFF);
-        tx_data.push_back(light & 0xFF);
-        logInfo("light: %lu [0x%04X]", light, light);
+        tx_data.push_back(++counter);
+        logInfo("sending uplink with data = %d", counter);
         send_data(tx_data);
 
-        // put the LSL29011 ambient light sensor into a low power state
-        lux.setMode(ISL29011::PWR_DOWN);
-#else 
-        // get some dummy data and send it to the gateway
-        light = lux.read_u16();
-        tx_data.push_back((light >> 8) & 0xFF);
-        tx_data.push_back(light & 0xFF);
-        logInfo("light: %lu [0x%04X]", light, light);
-        send_data(tx_data);
-#endif
-
         // 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);