Demonstration program for Multitech System MTDOT-EVB an evaluation board for the mDot LoRa module

Dependencies:   DOGS102 ISL29011 MMA845x MPL3115A2 NCP5623B libmDot mbed-rtos mbed

Revision:
4:49d19abdfd04
Parent:
3:68e974f5f532
Child:
7:85445a8cc189
Child:
8:6bf4d69651b7
--- a/main.cpp	Wed Jul 15 14:20:33 2015 +0000
+++ b/main.cpp	Thu Oct 22 19:36:34 2015 +0000
@@ -28,6 +28,10 @@
  *
  * 1.03 TAB 7/15/15 Added threads for push button switch debounce.
  *
+ * 1.04 TAB 10/22/15 Fixed format error in temperature print to LCD. Corrected error in
+ *					public netework setup. Swapped \n and \r in prinf calls because
+ *					Windows seems to be picky about the order
+ *
  */
 
 #include "mbed.h"
@@ -99,10 +103,16 @@
 /* **** replace these values with the proper public or private network settings ****
  * config_network_nameand config_network_pass are for private networks.
  */
+//settings for my bench
 static std::string config_network_name = "TAB-CubeNet";
 static std::string config_network_pass = "1nt3gral";
 static uint8_t config_frequency_sub_band = 5;
 
+//Default network server settings
+//static std::string config_network_name = "YOUR-NETWORK-NAME";
+//static std::string config_network_pass = "YOUR-NETWORK-PASSPHRASE";
+//static uint8_t config_frequency_sub_band = 3;
+
 /*  config_app_id and config_app_key are for public networks.
 static uint8_t app_id[8] = {0x00,0x01,0x02,0x03,0x0A,0x0B,0x0C,0x0D};
 std::vector<uint8_t> config_app_id;
@@ -203,8 +213,8 @@
     mDot15.mode(PullUp);
     mDot16.mode(PullUp);
 
-    printf("font table address %p\n\r",&font_6x8);
-    printf("bitmap address %p\n\r",&MultiTech_Logo);
+    printf("font table address %p\r\n",&font_6x8);
+    printf("bitmap address %p\r\n",&MultiTech_Logo);
 
 // Setup and display logo on LCD
     evbLCD->startUpdate();
@@ -220,7 +230,7 @@
 
     evbLCD->endUpdate();
 
-   printf("\n\r setup mdot\n\r");
+   printf("\r\n setup mdot\r\n");
 
     // get a mDot handle
     mdot_radio = mDot::getInstance();
@@ -240,7 +250,7 @@
         for (i=0; i<mdot_EUI.size(); i++) {
             printf("%02x ", mdot_EUI[i]);
         }
-        printf("\n\r");
+        printf("\r\n");
 
 
 // Setting up the mDot with network information.
@@ -273,7 +283,7 @@
 
         printf("setting network name\r\n");
         if ((mdot_ret = mdot_radio->setNetworkName(config_network_name)) != mDot::MDOT_OK) {
-//      if ((mdot_ret = mdot_radio->setNetworkID(config_app_id)) != mDot::MDOT_OK) {
+//      if ((mdot_ret = mdot_radio->setNetworkId(config_app_id)) != mDot::MDOT_OK) {
             log_error(mdot_radio, "failed to set network name", mdot_ret);
         }
 
@@ -301,7 +311,7 @@
         		mdot_ret = 0;
          	}
         		
-            printf("delay = %lu\n\r",mdot_ret);
+            printf("delay = %lu\r\n",mdot_ret);
             osDelay(mdot_ret + 1);
         }
 
@@ -309,7 +319,7 @@
          * Check for PB1 press during network join attempt
          */
         if (exit_program) {
-            printf("Exiting program\n\r");
+            printf("Exiting program\r\n");
             evbLCD->clearBuffer();
             sprintf(txtstr,"Exiting Program");
             evbLCD->writeText(0,4,font_6x8,txtstr,strlen(txtstr));
@@ -317,7 +327,7 @@
         }
 
     } else {
-        printf("radio setup failed\n\r");
+        printf("radio setup failed\r\n");
         //exit(1);
     }
 
@@ -327,26 +337,26 @@
     // sets LED2 to 50% max current
     evbBackLight->setLEDCurrent(16);
 
-    printf("Start of Test\n\r");
+    printf("Start of Test\r\n");
 
     osDelay (500);			// allows other threads to process
-    printf("shutdown LED:\n\r");
+    printf("shutdown LED:\r\n");
     evbBackLight->shutdown();
 
     osDelay (500);			// allows other threads to process
-    printf("Turn on LED2\n\r");
+    printf("Turn on LED2\r\n");
     evbBackLight->setLEDCurrent(16);
 
     data = evbAccel->getWhoAmI();
-    printf("Accelerometer who_am_i value = %x \n\r", data);
+    printf("Accelerometer who_am_i value = %x \r\n", data);
 
     result = evbAccel->getStatus();
-    printf("status byte = %x \n\r", result);
+    printf("status byte = %x \r\n", result);
 
-    printf("Barometer who_am_i check = %s \n\r", evbBaro->testWhoAmI() ? "TRUE" : "FALSE");
+    printf("Barometer who_am_i check = %s \r\n", evbBaro->testWhoAmI() ? "TRUE" : "FALSE");
 
     result = evbBaro->getStatus();
-    printf("status byte = %x \n\r", result);
+    printf("status byte = %x \r\n", result);
 
     /*
      *  Setup the Accelerometer for 8g range, 14 bit resolution, Noise reduction off, sample rate 1.56 Hz
@@ -386,7 +396,7 @@
      * Check for PB1 press during network join attempt
      */
     if (exit_program) {
-        printf("Exiting program\n\r");
+        printf("Exiting program\r\n");
         evbLCD->clearBuffer();
         sprintf(txtstr,"Exiting Program");
         evbLCD->writeText(0,4,font_6x8,txtstr,strlen(txtstr));
@@ -471,7 +481,7 @@
         baro_data._baro /= 4096;				// convert 32 bit signed to 20 bit signed value
         num_whole = baro_data._baro / 16;		//	18 bit signed significant integer
         num_frac = (baro_data._baro & 0xF) * 625 / 100;		// 4 bit fractional .0625 per bit
-        sprintf(txtstr,"Alti=%ld.%03d m", num_whole, num_frac);
+        sprintf(txtstr,"Alti=%ld.%02d m", num_whole, num_frac);
         evbLCD->writeText(0,5,font_6x8,txtstr,strlen(txtstr));
         num_whole = baro_data._temp / 16;		// 8 bit signed significant integer
         num_frac = (baro_data._temp & 0x0F) * 625 / 100;		// 4 bit fractional .0625 per bit
@@ -488,7 +498,7 @@
         evbLCD->writeText(0,7,font_6x8,txtstr,strlen(txtstr));
 
         evbLCD->endUpdate();
-        printf("finished iteration %d\n\r",(++i));
+        printf("finished iteration %d\r\n",(++i));
 
         if (i % pckt_time == 0) { // check packet counter will send packet every 2-5-10 data collection loops
             mdot_data.clear();
@@ -529,10 +539,10 @@
     } while ((result & MPL3115A2::PTDR) == 0 );
 
     baro_data = evbBaro->getAllData(true);
-    printf ("minBaro=%ld maxBaro=%ld minTemp=%d maxTemp=%d\n\r", baro_data._minbaro, baro_data._maxbaro,
+    printf ("minBaro=%ld maxBaro=%ld minTemp=%d maxTemp=%d\r\n", baro_data._minbaro, baro_data._maxbaro,
             baro_data._mintemp, baro_data._maxtemp);
 
-    printf("End of Test\n\r");
+    printf("End of Test\r\n");
 
     evbLCD->clearBuffer();
     sprintf(txtstr,"Exiting Program");