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

Revision:
42:20f6b29a9903
Parent:
33:15ea8f985c54
diff -r 67feacfab49c -r 20f6b29a9903 examples/src/class_b_example.cpp
--- a/examples/src/class_b_example.cpp	Mon May 18 13:12:47 2020 -0500
+++ b/examples/src/class_b_example.cpp	Tue May 25 09:54:33 2021 -0500
@@ -38,7 +38,7 @@
 mDot* dot = NULL;
 lora::ChannelPlan* plan = NULL;
 
-Serial pc(USBTX, USBRX);
+mbed::UnbufferedSerial pc(USBTX, USBRX);
 
 #if defined(TARGET_XDOT_L151CC)
 I2C i2c(I2C_SDA, I2C_SCL);
@@ -58,22 +58,9 @@
 #endif
 
     mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
-    
-#if CHANNEL_PLAN == CP_US915
-    plan = new lora::ChannelPlan_US915();
-#elif CHANNEL_PLAN == CP_AU915
-    plan = new lora::ChannelPlan_AU915();
-#elif CHANNEL_PLAN == CP_EU868
-    plan = new lora::ChannelPlan_EU868();
-#elif CHANNEL_PLAN == CP_KR920
-    plan = new lora::ChannelPlan_KR920();
-#elif CHANNEL_PLAN == CP_AS923
-    plan = new lora::ChannelPlan_AS923();
-#elif CHANNEL_PLAN == CP_AS923_JAPAN
-    plan = new lora::ChannelPlan_AS923_Japan();
-#elif CHANNEL_PLAN == CP_IN865
-    plan = new lora::ChannelPlan_IN865();
-#endif
+
+    // Create channel plan
+    plan = create_channel_plan();
     assert(plan);
 
     dot = mDot::getInstance(plan);
@@ -158,11 +145,11 @@
             srand(dot->getRadioRandom());
             uint32_t rand_delay = rand() % 5000;
             logInfo("Applying a random delay of %d ms before class notification uplink", rand_delay);
-            osDelay(rand_delay);
+            ThisThread::sleep_for(std::chrono::milliseconds(rand_delay));
 
             // Ensure the link is idle before trying to transmit
             while (!dot->getIsIdle()) {
-                osDelay(10);
+                ThisThread::sleep_for(10ms);
             }
 
             if (send_data(tx_data) != mDot::MDOT_OK) {
@@ -187,8 +174,7 @@
                 bcn_timer.reset();
             }
         }
-
-        Thread::wait(10000);
+        ThisThread::sleep_for(10s);
     }
 
     return 0;