Start project of The Things Network workshop with the MultiTech mDot

Dependencies:   libmDot mbed-rtos mbed

Fork of mDot_LoRa_Connect_Example_APP_EUI_KEY by MultiTech

Files at this revision

API Documentation at this revision

Comitter:
johanstokking
Date:
Tue Apr 05 16:48:13 2016 +0000
Parent:
11:690e594d3745
Child:
13:6ce90b84a3fe
Commit message:
Added comments

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Apr 05 16:45:39 2016 +0000
+++ b/main.cpp	Tue Apr 05 16:48:13 2016 +0000
@@ -14,23 +14,31 @@
 void setupNetwork();
 
 int main() {
+    // Set up the network
     setupNetwork();
     
+    // Message you want to send
     std::string data_str = "Hello!";
 
+    // Copy the message in an array of bytes
     std::vector<uint8_t> data;
     for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++)
         data.push_back((uint8_t) *it);
     
+    // Start the loop
     int32_t ret;
     while (true) {
+        // Send the data
         if ((ret = dot->send(data)) != mDot::MDOT_OK) {
+            // Oops, there was an error, check the debug screen
             logError("Failed to send", ret, mDot::getReturnCodeString(ret).c_str());
         } else {
+            // Sent the data
             logInfo("Successfully sent data");
         }
         
-        osDelay(std::max((uint32_t)20000, (uint32_t)dot->getNextTxMs()));
+        // Wait 5 seconds
+        osDelay(std::max((uint32_t)5000, (uint32_t)dot->getNextTxMs()));
     }
 
     return 0;