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

Revision:
5:97ed5f2f099e
Parent:
3:0e3e776e2862
Child:
9:72d3203279b2
--- a/examples/src/ota_example.cpp	Thu Oct 06 22:12:21 2016 +0000
+++ b/examples/src/ota_example.cpp	Fri Oct 07 10:38:54 2016 -0500
@@ -2,13 +2,17 @@
  
 #if ACTIVE_EXAMPLE == OTA_EXAMPLE
 
-///////////////////////////////////////////////////////////
-// these options must match the settings on your gateway //
-// edit their values to match your configuration         //
-// frequency sub band is only relevant for the 915 bands //
-///////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////
+// * these options must match the settings on your gateway //
+// * edit their values to match your configuration         //
+// * frequency sub band is only relevant for the 915 bands //
+// * either the network name and passphrase can be used or //
+//     the network ID (8 bytes) and KEY (16 bytes)         //
+/////////////////////////////////////////////////////////////
 static std::string network_name = "MultiTech";
 static std::string network_passphrase = "MultiTech";
+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 uint8_t ack = 1;
@@ -40,15 +44,19 @@
     // make sure library logging is turned on
     dot->setLogLevel(mts::MTSLog::INFO_LEVEL);
 
-    // update configuration if necessary, then display it
+    // update configuration if necessary
     if (dot->getJoinMode() != mDot::OTA) {
         logInfo("changing network join mode to OTA");
         if (dot->setJoinMode(mDot::OTA) != mDot::MDOT_OK) {
             logError("failed to set network join mode to OTA");
         }
     }
-    update_ota_config(network_name, network_passphrase, frequency_sub_band, public_network, ack);
-    display_config();
+    // in OTA and AUTO_OTA join modes, the credentials can be passed to the library as a name and passphrase or an EUI and KEY
+    // 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);
+    //update_ota_config_id_key(network_id, network_key, frequency_sub_band, public_network, ack);
 
     // restore the saved session if the dot woke from deepsleep mode
     // useful to use with deepsleep because session info is otherwise lost when the dot enters deepsleep
@@ -57,6 +65,9 @@
         dot->restoreNetworkSession();
     }
     
+    // display configuration
+    display_config();
+
     while (true) {
         uint16_t light;
         std::vector<uint8_t> tx_data;