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

Revision:
30:2f5ae37e6c47
Parent:
29:9e2c0d990ace
Child:
31:b1d5811e3d5d
diff -r 9e2c0d990ace -r 2f5ae37e6c47 examples/src/manual_example.cpp
--- a/examples/src/manual_example.cpp	Fri Apr 20 14:42:46 2018 -0500
+++ b/examples/src/manual_example.cpp	Mon Apr 30 14:46:28 2018 -0500
@@ -24,6 +24,7 @@
 static uint8_t network_session_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
 static uint8_t data_session_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
 static uint8_t frequency_sub_band = 6;
+static bool public_network = true;
 static uint8_t join_delay = 5;
 static uint8_t ack = 1;
 static bool adr = true;
@@ -39,12 +40,23 @@
 
 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;
 
     pc.baud(115200);
 
+#if defined(TARGET_XDOT_L151CC)
+    i2c.frequency(400000);
+#endif
+
     mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
     
 #if CHANNEL_PLAN == CP_US915
@@ -99,7 +111,7 @@
         //      lora-query -a 01020304 A 0102030401020304 <your Dot's device ID> 01020304010203040102030401020304 01020304010203040102030401020304
         //   * if you change the network address, network session key, or data session key, make sure you update them on the gateway
         // to provision your Dot with a 3rd party gateway, see the gateway or network provider documentation
-        update_manual_config(network_address, network_session_key, data_session_key, frequency_sub_band, ack);
+        update_manual_config(network_address, network_session_key, data_session_key, frequency_sub_band, public_network, ack);
 
         // enable or disable Adaptive Data Rate
         dot->setAdr(adr);
@@ -122,15 +134,34 @@
         dot->restoreNetworkSession();
     }
     
-
-    uint8_t counter = 0;
     while (true) {
+        uint16_t light;
         std::vector<uint8_t> tx_data;
 
-        tx_data.push_back(++counter);
-        logInfo("sending uplink with data = %d", counter);
+#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);
         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
+
         // 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) {