l

Dependencies:   mbed LoRaWAN-lib SX1272Lib

Fork of LoRaWAN-demo-72 by Semtech

Files at this revision

API Documentation at this revision

Comitter:
SvenKbach
Date:
Tue Dec 06 13:51:36 2016 +0000
Parent:
6:38d6cc1ff868
Commit message:
No VT100

Changed in this revision

app/Comissioning.h Show annotated file Show diff for this revision Revisions of this file
app/main.cpp Show annotated file Show diff for this revision Revisions of this file
mac/LoRaWAN-lib.lib Show annotated file Show diff for this revision Revisions of this file
radio/SX1272Lib.lib Show annotated file Show diff for this revision Revisions of this file
--- a/app/Comissioning.h	Thu Dec 01 09:07:19 2016 +0000
+++ b/app/Comissioning.h	Tue Dec 06 13:51:36 2016 +0000
@@ -34,8 +34,11 @@
 /*!
  * Mote device IEEE EUI (big endian)
  */
+#if OVER_THE_AIR_ACTIVATION
 #define LORAWAN_DEVICE_EUI                          { 0x70, 0xb3, 0xd5, 0xb0, 0x20, 0x00, 0x00, 0x2d}
-
+#else
+#define LORAWAN_DEVICE_EUI              {0x70, 0xb3, 0xd5, 0xb0, 0x20, 0x00, 0x00, 0x3d}
+#endif
 /*!
  * Application IEEE EUI (big endian)
  */
@@ -44,7 +47,11 @@
 /*!
  * AES encryption/decryption cipher application key
  */
+#if OVER_THE_AIR_ACTIVATION
 #define LORAWAN_APPLICATION_KEY                     { 0x6f, 0xe7, 0x25, 0x89, 0x46, 0x88, 0x7a, 0x0e, 0x39, 0x8e, 0x57, 0x80, 0x28, 0x48, 0x37, 0x9f }
+#else
+#define LORAWAN_APPLICATION_KEY             {0x2b, 0x56, 0x86, 0x4d, 0xf8, 0x57, 0x07, 0xff, 0xe6, 0x2e, 0x39, 0xa4, 0xd9, 0x3a, 0x44, 0xb1}
+#endif
 
 /*!
  * Current network ID
@@ -54,16 +61,20 @@
 /*!
  * Device address on the network (big endian)
  */
+#if OVER_THE_AIR_ACTIVATION
 #define LORAWAN_DEVICE_ADDRESS                      ( uint32_t )0x12345678
+#else
+#define LORAWAN_DEVICE_ADDRESS              (uint32_t)0x0558ef68
+#endif
 
 /*!
  * AES encryption/decryption cipher network session key
  */
-#define LORAWAN_NWKSKEY                             { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }
+#define LORAWAN_NWKSKEY                             { 0xcc, 0xc7, 0x25, 0x89, 0x46, 0x88, 0x7a, 0x0e, 0x39, 0x8e, 0x57, 0x80, 0x28, 0x48, 0x3d, 0xdd }
 
 /*!
  * AES encryption/decryption cipher application session key
  */
-#define LORAWAN_APPSKEY                             { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }
+#define LORAWAN_APPSKEY                             { 0xaa, 0xa7, 0x25, 0x89, 0x46, 0x88, 0x7a, 0x0e, 0x39, 0x8e, 0x57, 0x80, 0x28, 0x48, 0x3b, 0xbb }
 
 #endif // __LORA_COMMISSIONING_H__
--- a/app/main.cpp	Thu Dec 01 09:07:19 2016 +0000
+++ b/app/main.cpp	Tue Dec 06 13:51:36 2016 +0000
@@ -18,12 +18,12 @@
 
 #include "LoRaMac.h"
 #include "Comissioning.h"
-#include "SerialDisplay.h"
+//#include "SerialDisplay.h"
 
 /*!
  * Defines the application data transmission duty cycle. 5s, value in [us].
  */
-#define APP_TX_DUTYCYCLE                            5000000
+#define APP_TX_DUTYCYCLE                            50000000
 
 /*!
  * Defines a random delay for application data transmission duty cycle. 1s,
@@ -57,7 +57,7 @@
  *
  * \remark Please note that ETSI mandates duty cycled transmissions. Use only for test purposes
  */
-#define LORAWAN_DUTYCYCLE_ON                        true
+#define LORAWAN_DUTYCYCLE_ON                        false
 
 #define USE_SEMTECH_DEFAULT_CHANNEL_LINEUP          1
 
@@ -145,20 +145,20 @@
 /*!
  * Specifies the state of the application LED
  */
-static bool AppLedStateOn = false;
-volatile bool Led3StateChanged = false;
+//static bool AppLedStateOn = false;
+//volatile bool Led3StateChanged = false;
 /*!
  * Timer to handle the state of LED1
  */
-static TimerEvent_t Led1Timer;
-volatile bool Led1State = false;
-volatile bool Led1StateChanged = false;
+//static TimerEvent_t Led1Timer;
+//volatile bool Led1State = false;
+//volatile bool Led1StateChanged = false;
 /*!
  * Timer to handle the state of LED2
  */
-static TimerEvent_t Led2Timer;
-volatile bool Led2State = false;
-volatile bool Led2StateChanged = false;
+//static TimerEvent_t Led2Timer;
+//volatile bool Led2State = false;
+//volatile bool Led2StateChanged = false;
 
 /*!
  * Indicates if a new packet can be sent
@@ -236,37 +236,37 @@
 {
     MibRequestConfirm_t mibReq;
 
-    SerialDisplayInit( );
-    SerialDisplayUpdateActivationMode( OVER_THE_AIR_ACTIVATION );
+    //SerialDisplayInit( );
+    //SerialDisplayUpdateActivationMode( OVER_THE_AIR_ACTIVATION );
 
 #if( OVER_THE_AIR_ACTIVATION == 0 )
-    SerialDisplayUpdateNwkId( LORAWAN_NETWORK_ID );
-    SerialDisplayUpdateDevAddr( DevAddr );
-    SerialDisplayUpdateKey( 12, NwkSKey );
-    SerialDisplayUpdateKey( 13, AppSKey );
+    //SerialDisplayUpdateNwkId( LORAWAN_NETWORK_ID );
+    //SerialDisplayUpdateDevAddr( DevAddr );
+    //SerialDisplayUpdateKey( 12, NwkSKey );
+   // SerialDisplayUpdateKey( 13, AppSKey );
 #endif
-    SerialDisplayUpdateEui( 5, DevEui );
-    SerialDisplayUpdateEui( 6, AppEui );
-    SerialDisplayUpdateKey( 7, AppKey );
+   // SerialDisplayUpdateEui( 5, DevEui );
+   // SerialDisplayUpdateEui( 6, AppEui );
+   // SerialDisplayUpdateKey( 7, AppKey );
 
     mibReq.Type = MIB_NETWORK_JOINED;
     LoRaMacMibGetRequestConfirm( &mibReq );
-    SerialDisplayUpdateNetworkIsJoined( mibReq.Param.IsNetworkJoined );
+   // SerialDisplayUpdateNetworkIsJoined( mibReq.Param.IsNetworkJoined );
 
-    SerialDisplayUpdateAdr( LORAWAN_ADR_ON );
+   // SerialDisplayUpdateAdr( LORAWAN_ADR_ON );
 #if defined( USE_BAND_868 )
-    SerialDisplayUpdateDutyCycle( LORAWAN_DUTYCYCLE_ON );
+   // SerialDisplayUpdateDutyCycle( LORAWAN_DUTYCYCLE_ON );
 #else
-    SerialDisplayUpdateDutyCycle( false );
+  //  SerialDisplayUpdateDutyCycle( false );
 #endif
-    SerialDisplayUpdatePublicNetwork( LORAWAN_PUBLIC_NETWORK );
+    //SerialDisplayUpdatePublicNetwork( LORAWAN_PUBLIC_NETWORK );
     
-    SerialDisplayUpdateLedState( 3, AppLedStateOn );
+   // SerialDisplayUpdateLedState( 3, AppLedStateOn );
 }
 
 void SerialRxProcess( void )
 {
-    if( SerialDisplayReadable( ) == true )
+  /*  if( SerialDisplayReadable( ) == true )
     {
         switch( SerialDisplayGetChar( ) )
         {
@@ -278,7 +278,7 @@
             default:
                 break;
         }
-    }
+    }*/
 }
 
 /*!
@@ -290,7 +290,7 @@
     {
     case 1:
         {
-            AppData[0] = AppLedStateOn;
+            AppData[0] = 1;//AppLedStateOn;
             if( IsTxConfirmed == true )
             {
                 AppData[1] = LoRaMacDownlinkStatus.DownlinkCounter >> 8;
@@ -353,7 +353,7 @@
         LoRaMacUplinkStatus.Port = 0;
         LoRaMacUplinkStatus.Buffer = NULL;
         LoRaMacUplinkStatus.BufferSize = 0;
-        SerialDisplayUpdateFrameType( false );
+       // SerialDisplayUpdateFrameType( false );
     }
     else
     {
@@ -361,7 +361,7 @@
         LoRaMacUplinkStatus.Port = AppPort;
         LoRaMacUplinkStatus.Buffer = AppData;
         LoRaMacUplinkStatus.BufferSize = AppDataSize;
-        SerialDisplayUpdateFrameType( IsTxConfirmed );
+      //  SerialDisplayUpdateFrameType( IsTxConfirmed );
 
         if( IsTxConfirmed == false )
         {
@@ -419,24 +419,24 @@
 /*!
  * \brief Function executed on Led 1 Timeout event
  */
-static void OnLed1TimerEvent( void )
+/*static void OnLed1TimerEvent( void )
 {
     TimerStop( &Led1Timer );
-    // Switch LED 1 OFF
+    Switch LED 1 OFF
     Led1State = false;
     Led1StateChanged = true;
-}
+}*/
 
 /*!
  * \brief Function executed on Led 2 Timeout event
  */
-static void OnLed2TimerEvent( void )
+/*static void OnLed2TimerEvent( void )
 {
     TimerStop( &Led2Timer );
-    // Switch LED 2 OFF
+    Switch LED 2 OFF
     Led2State = false;
     Led2StateChanged = true;
-}
+}*/
 
 /*!
  * \brief   MCPS-Confirm event function
@@ -476,9 +476,9 @@
         LoRaMacUplinkStatus.UplinkCounter = mcpsConfirm->UpLinkCounter;
 
         // Switch LED 1 ON
-        Led1State = true;
-        Led1StateChanged = true;
-        TimerStart( &Led1Timer );
+      //  Led1State = true;
+      //  Led1StateChanged = true;
+      //  TimerStart( &Led1Timer );
 
         UplinkStatusUpdated = true;
     }
@@ -560,8 +560,8 @@
         case 2:
             if( mcpsIndication->BufferSize == 1 )
             {
-                AppLedStateOn = mcpsIndication->Buffer[0] & 0x01;
-                Led3StateChanged = true;
+             //   AppLedStateOn = mcpsIndication->Buffer[0] & 0x01;
+             //   Led3StateChanged = true;
             }
             break;
         case 224:
@@ -666,9 +666,9 @@
     }
 
     // Switch LED 2 ON for each received downlink
-    Led2State = true;
-    Led2StateChanged = true;
-    TimerStart( &Led2Timer );
+    //Led2State = true;
+    //Led2StateChanged = true;
+   // TimerStart( &Led2Timer );
     DownlinkStatusUpdated = true;
 }
 
@@ -722,17 +722,17 @@
     MibRequestConfirm_t mibReq;
 
     BoardInit( );
-    SerialDisplayInit( );
+   // SerialDisplayInit( );
 
-    SerialDisplayUpdateEui( 5, DevEui );
-    SerialDisplayUpdateEui( 6, AppEui );
-    SerialDisplayUpdateKey( 7, AppKey );
+   // SerialDisplayUpdateEui( 5, DevEui );
+  //  SerialDisplayUpdateEui( 6, AppEui );
+  //  SerialDisplayUpdateKey( 7, AppKey );
 
 #if( OVER_THE_AIR_ACTIVATION == 0 )
-    SerialDisplayUpdateNwkId( LORAWAN_NETWORK_ID );
+   /* SerialDisplayUpdateNwkId( LORAWAN_NETWORK_ID );
     SerialDisplayUpdateDevAddr( DevAddr );
     SerialDisplayUpdateKey( 12, NwkSKey );
-    SerialDisplayUpdateKey( 13, AppSKey );
+    SerialDisplayUpdateKey( 13, AppSKey );*/
 #endif
 
     DeviceState = DEVICE_STATE_INIT;
@@ -745,33 +745,33 @@
             IsNetworkJoinedStatusUpdate = false;
             mibReq.Type = MIB_NETWORK_JOINED;
             LoRaMacMibGetRequestConfirm( &mibReq );
-            SerialDisplayUpdateNetworkIsJoined( mibReq.Param.IsNetworkJoined );
+  //          SerialDisplayUpdateNetworkIsJoined( mibReq.Param.IsNetworkJoined );
         }
-        if( Led1StateChanged == true )
+       /* if( Led1StateChanged == true )
         {
             Led1StateChanged = false;
-            SerialDisplayUpdateLedState( 1, Led1State );
+ //           SerialDisplayUpdateLedState( 1, Led1State );
         }
         if( Led2StateChanged == true )
         {
             Led2StateChanged = false;
-            SerialDisplayUpdateLedState( 2, Led2State );
+  //          SerialDisplayUpdateLedState( 2, Led2State );
         }
         if( Led3StateChanged == true )
         {
             Led3StateChanged = false;
-            SerialDisplayUpdateLedState( 3, AppLedStateOn );
-        }
+  //          SerialDisplayUpdateLedState( 3, AppLedStateOn );
+        }*/
         if( UplinkStatusUpdated == true )
         {
             UplinkStatusUpdated = false;
-            SerialDisplayUpdateUplink( LoRaMacUplinkStatus.Acked, LoRaMacUplinkStatus.Datarate, LoRaMacUplinkStatus.UplinkCounter, LoRaMacUplinkStatus.Port, LoRaMacUplinkStatus.Buffer, LoRaMacUplinkStatus.BufferSize );
+  //          SerialDisplayUpdateUplink( LoRaMacUplinkStatus.Acked, LoRaMacUplinkStatus.Datarate, LoRaMacUplinkStatus.UplinkCounter, LoRaMacUplinkStatus.Port, LoRaMacUplinkStatus.Buffer, LoRaMacUplinkStatus.BufferSize );
         }
         if( DownlinkStatusUpdated == true )
         {
             DownlinkStatusUpdated = false;
-            SerialDisplayUpdateLedState( 2, Led2State );
-            SerialDisplayUpdateDownlink( LoRaMacDownlinkStatus.RxData, LoRaMacDownlinkStatus.Rssi, LoRaMacDownlinkStatus.Snr, LoRaMacDownlinkStatus.DownlinkCounter, LoRaMacDownlinkStatus.Port, LoRaMacDownlinkStatus.Buffer, LoRaMacDownlinkStatus.BufferSize );
+  //          SerialDisplayUpdateLedState( 2, Led2State );
+  //          SerialDisplayUpdateDownlink( LoRaMacDownlinkStatus.RxData, LoRaMacDownlinkStatus.Rssi, LoRaMacDownlinkStatus.Snr, LoRaMacDownlinkStatus.DownlinkCounter, LoRaMacDownlinkStatus.Port, LoRaMacDownlinkStatus.Buffer, LoRaMacDownlinkStatus.BufferSize );
         }
         
         switch( DeviceState )
@@ -786,11 +786,11 @@
 
                 TimerInit( &TxNextPacketTimer, OnTxNextPacketTimerEvent );
 
-                TimerInit( &Led1Timer, OnLed1TimerEvent );
-                TimerSetValue( &Led1Timer, 25000 );
+             //   TimerInit( &Led1Timer, OnLed1TimerEvent );
+             //   TimerSetValue( &Led1Timer, 25000 );
 
-                TimerInit( &Led2Timer, OnLed2TimerEvent );
-                TimerSetValue( &Led2Timer, 25000 );
+             //   TimerInit( &Led2Timer, OnLed2TimerEvent );
+              //  TimerSetValue( &Led2Timer, 25000 );
 
                 mibReq.Type = MIB_ADR;
                 mibReq.Param.AdrEnable = LORAWAN_ADR_ON;
@@ -800,9 +800,13 @@
                 mibReq.Param.EnablePublicNetwork = LORAWAN_PUBLIC_NETWORK;
                 LoRaMacMibSetRequestConfirm( &mibReq );
 
+                mibReq.Type = MIB_DEVICE_CLASS;
+                mibReq.Param.Class = CLASS_C;
+                LoRaMacMibSetRequestConfirm( &mibReq );
+
 #if defined( USE_BAND_868 )
                 LoRaMacTestSetDutyCycleOn( LORAWAN_DUTYCYCLE_ON );
-                SerialDisplayUpdateDutyCycle( LORAWAN_DUTYCYCLE_ON );
+     //           SerialDisplayUpdateDutyCycle( LORAWAN_DUTYCYCLE_ON );
 
 #if( USE_SEMTECH_DEFAULT_CHANNEL_LINEUP == 1 ) 
                 LoRaMacChannelAdd( 3, ( ChannelParams_t )LC4 );
@@ -819,9 +823,9 @@
 #endif
 
 #endif
-                SerialDisplayUpdateActivationMode( OVER_THE_AIR_ACTIVATION );
-                SerialDisplayUpdateAdr( LORAWAN_ADR_ON );
-                SerialDisplayUpdatePublicNetwork( LORAWAN_PUBLIC_NETWORK );
+     //           SerialDisplayUpdateActivationMode( OVER_THE_AIR_ACTIVATION );
+    //            SerialDisplayUpdateAdr( LORAWAN_ADR_ON );
+     //           SerialDisplayUpdatePublicNetwork( LORAWAN_PUBLIC_NETWORK );
 
                 LoRaMacDownlinkStatus.DownlinkCounter = 0;
 
@@ -874,8 +878,8 @@
             {
                 if( NextTx == true )
                 {
-                    SerialDisplayUpdateUplinkAcked( false );
-                    SerialDisplayUpdateDonwlinkRxData( false );
+     //               SerialDisplayUpdateUplinkAcked( false );
+     //               SerialDisplayUpdateDonwlinkRxData( false );
                     PrepareTxFrame( AppPort );
 
                     NextTx = SendFrame( );
@@ -883,7 +887,7 @@
                 if( ComplianceTest.Running == true )
                 {
                     // Schedule next packet transmission
-                    TxDutyCycleTime = 5000000; // 5000000 us
+                    TxDutyCycleTime = 50000000; // 5000000 us
                 }
                 else
                 {
--- a/mac/LoRaWAN-lib.lib	Thu Dec 01 09:07:19 2016 +0000
+++ b/mac/LoRaWAN-lib.lib	Tue Dec 06 13:51:36 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Semtech/code/LoRaWAN-lib/#c16969e0f70f
+http://developer.mbed.org/teams/Semtech/code/LoRaWAN-lib/#21b06103f9ed
--- a/radio/SX1272Lib.lib	Thu Dec 01 09:07:19 2016 +0000
+++ b/radio/SX1272Lib.lib	Tue Dec 06 13:51:36 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Semtech/code/SX1272Lib/#69d5976b504d
+http://developer.mbed.org/teams/Semtech/code/SX1272Lib/#f15b7831a378