Lora OTA device for Everynet

Dependencies:   LMiCLibOTADeviceEverynet SX1276Lib X_NUCLEO_IKS01A1 cantcoap lwip mbed-rtos mbed

Fork of LoRaWAN-test-10secs by Alcatel-Lucent IoT Development

Files at this revision

API Documentation at this revision

Comitter:
pnysten
Date:
Fri Sep 23 09:18:35 2016 +0000
Parent:
13:9de42df1d3d8
Commit message:
Lora OTA device for Everynet

Changed in this revision

LMiC.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/LMiC.lib	Tue Feb 23 08:43:37 2016 +0000
+++ b/LMiC.lib	Fri Sep 23 09:18:35 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/Alcatel-Lucent-IoT-Development/code/LMiC-10secs/#c5820ce68bd6
+https://developer.mbed.org/teams/Alcatel-Lucent-IoT-Development/code/LMiCLibOTADeviceEverynet/#8f33a411b53f
--- a/main.cpp	Tue Feb 23 08:43:37 2016 +0000
+++ b/main.cpp	Fri Sep 23 09:18:35 2016 +0000
@@ -72,7 +72,7 @@
  * When set to 1 the application uses the Over-the-Air activation procedure
  * When set to 0 the application uses the Personalization activation procedure
  */
-#define OVER_THE_AIR_ACTIVATION                     0
+#define OVER_THE_AIR_ACTIVATION                     1
 
 #if( OVER_THE_AIR_ACTIVATION == 0 )
 
@@ -262,7 +262,7 @@
 
 std::string to_string( int x ) {
   int length = snprintf( NULL, 0, "%d", x );
-  assert( length >= 0 );
+  //assert( length >= 0 );
   char* buf = new char[length + 1];
   snprintf( buf, length + 1, "%d", x );
   std::string str( buf );
@@ -368,15 +368,15 @@
 //To be changed when switching from one to another
 static const uint8_t AppEui[8] =
 {
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-//    0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
+//    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+    0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
 };
 
 // unique device ID (LSBF)
 //To be changed when switching from one to another
 static const u1_t DevEui[8] =
 {
-      0x33, 0x74, 0x73, 0x65, 0x74, 0x2D, 0x52, 0x4C // 4c522d7465737433 = "LR-test3"
+      0x31, 0x74, 0x73, 0x65, 0x74, 0x2D, 0x52, 0x4C // 4c522d7465737433 = "LR-test3"
 };
 
 // device-specific AES key (derived from device EUI)
@@ -524,12 +524,13 @@
 {
     std::string frame = "";
     std::string tmp;
-    debug_str("\r\n");
+//    debug_str("\r\n");
 
     temp_sensor1->GetTemperature(&value1);
     humidity_sensor->GetHumidity(&value2);
-    debug_str("HTS221: [temp] ");
-    debug_str(printDouble(buffer1, value1));
+    printDouble(buffer1, value1);
+//    debug_str("HTS221: [temp] ");
+//    debug_str(printDouble(buffer1, value1));
     tmp = "0,";
     tmp += buffer1;
     tmp += ",";
@@ -539,9 +540,9 @@
         temp_sent = true;
         frame += tmp; 
     }
-    
-    debug_str("Celsius,   [hum] ");
-    debug_str(printDouble(buffer2, value2));
+    printDouble(buffer2, value2);
+//    debug_str("Celsius,   [hum] ");
+//    debug_str(printDouble(buffer2, value2));
     tmp = "1,";
     tmp += buffer2;
     tmp += ",";
@@ -552,15 +553,17 @@
         frame += tmp; 
     }
     
-    debug_str("%\r\n");
+//    debug_str("%\r\n");
     //pc.printf("HTS221: [temp] %7s°C,   [hum] %s%%\r\n", printDouble(buffer1, value1), printDouble(buffer2, value2));
     
     temp_sensor2->GetFahrenheit(&value1);
     pressure_sensor->GetPressure(&value2);
-    debug_str("LPS25H: [temp] ");
+    printDouble(buffer1, value1);
+    printDouble(buffer2, value2);
+/*    debug_str("LPS25H: [temp] ");
     debug_str(printDouble(buffer1, value1));
     debug_str("Farenheit, [press] ");
-    debug_str(printDouble(buffer2, value2));
+    debug_str(printDouble(buffer2, value2));*/
     tmp = "2,";
     tmp += buffer2;
     tmp += ",";
@@ -571,19 +574,22 @@
         frame += tmp; 
     }
     
-    debug_str("mbar\r\n");
+//    debug_str("mbar\r\n");
     //pc.printf("LPS25H: [temp] %7s°F, [press] %smbar\r\n", printDouble(buffer1, value1), printDouble(buffer2, value2));
 
-    debug_str("---\r\n");
+//    debug_str("---\r\n");
 
     magnetometer->Get_M_Axes(axes);
-    debug_str("LIS3MDL [mag/mgauss]:  ");
+    printInt(buffer1, axes[0]);
+    printInt(buffer2, axes[1]);
+    printInt(buffer3, axes[2]);
+/*    debug_str("LIS3MDL [mag/mgauss]:  ");
     debug_str(printInt(buffer1, axes[0]));
     debug_str(", ");
     debug_str(printInt(buffer2, axes[1]));
     debug_str(", ");
     debug_str(printInt(buffer3, axes[2]));
-    debug_str("\r\n");
+    debug_str("\r\n");*/
     tmp = "3,";
     tmp += buffer1;
     tmp += ";";
@@ -601,12 +607,16 @@
     //pc.printf("LIS3MDL [mag/mgauss]:  %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]);
 
     accelerometer->Get_X_Axes(axes);
-    debug_str("LSM6DS0 [acc/mg]:      ");
+    printInt(buffer1, axes[0]);
+    printInt(buffer2, axes[1]);
+    printInt(buffer3, axes[2]);
+/*   debug_str("LSM6DS0 [acc/mg]:      ");
+
     debug_str(printInt(buffer1, axes[0]));
     debug_str(", ");
     debug_str(printInt(buffer2, axes[1]));
     debug_str(", ");
-    debug_str(printInt(buffer3, axes[2]));
+    debug_str(printInt(buffer3, axes[2]));*/
     tmp = "4,";
     tmp += buffer1;
     tmp += ";";
@@ -621,16 +631,19 @@
         frame += tmp; 
     }
     
-    debug_str("\r\n");
+    //debug_str("\r\n");
     //pc.printf("LSM6DS0 [acc/mg]:      %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]);
 
     gyroscope->Get_G_Axes(axes);
-    debug_str("LSM6DS0 [gyro/mdps]:   ");
+    printInt(buffer1, axes[0]);
+    printInt(buffer2, axes[1]);
+    printInt(buffer3, axes[2]);
+/*    debug_str("LSM6DS0 [gyro/mdps]:   ");
     debug_str(printInt(buffer1, axes[0]));
     debug_str(", ");
     debug_str(printInt(buffer2, axes[1]));
     debug_str(", ");
-    debug_str(printInt(buffer3, axes[2]));
+    debug_str(printInt(buffer3, axes[2]));*/
     tmp = "5,";
     tmp += buffer1;
     tmp += ";";
@@ -650,9 +663,9 @@
         frame += tmp; 
     }
     
-    debug_str("\r\n Frame: ");
-    debug_str(frame.c_str());
-    debug_str("\r\n");
+    //debug_str("\r\n Frame: ");
+    //debug_str(frame.c_str());
+    //debug_str("\r\n");
     //pc.printf("LSM6DS0 [gyro/mdps]:   %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]);
 
     strncpy((char*) LMIC.frame, frame.c_str(), strlen(frame.c_str()));
@@ -664,9 +677,9 @@
     LMIC.frame[strlen(frame.c_str())+3] = LMIC.rssi;
     LMIC.frame[strlen(frame.c_str())+4] = LMIC.snr;
 #endif
-    debug_str("Frame to be sent: ");
+    //debug_str("Frame to be sent: ");
 //    debug_buf(LMIC.frame, strlen(frame) + 5);
-    debug_buf(LMIC.frame, strlen(frame.c_str()));
+    //debug_buf(LMIC.frame, strlen(frame.c_str()));
     
 //    LoRaWAN_data_size = strlen(frame) + 5;
     LoRaWAN_data_size = strlen(frame.c_str());
@@ -682,8 +695,8 @@
     LMIC.frame[4] = LMIC.rssi;
     LMIC.frame[5] = LMIC.snr;
 #endif    
-    debug_str("Frame to be sent: ");
-    debug_buf(LMIC.frame, LORAWAN_APP_DATA_SIZE);
+    //debug_str("Frame to be sent: ");
+    //debug_buf(LMIC.frame, LORAWAN_APP_DATA_SIZE);
     
     LoRaWAN_data_size = LORAWAN_APP_DATA_SIZE;
 }
@@ -739,8 +752,12 @@
     //prepareTxCoapFrame();
     prepareTxSensorsFrame();
     //prepareTxLoraFrame();
-
-    LMIC_setTxData2( LORAWAN_APP_PORT, LMIC.frame, LoRaWAN_data_size, LORAWAN_CONFIRMED_MSG_ON );
+#if( OVER_THE_AIR_ACTIVATION == 1 )
+    LMIC_setTxData2( LORAWAN_APP_PORT, LMIC.frame, LoRaWAN_data_size, LORAWAN_CONFIRMED_MSG_ON, 0 );
+#endif  
+#if( OVER_THE_AIR_ACTIVATION == 0 )
+    LMIC_setTxData2( LORAWAN_APP_PORT, LMIC.frame, LoRaWAN_data_size, LORAWAN_CONFIRMED_MSG_ON, 0 );
+#endif  
 
     // Blink Tx LED
     //debug_val( "LED1 = ", 1 );