
Bootcamp application example using LoRaWAN-lib MAC layer implementation. Provides an application example controlling a 3 color LED and a light sensor.
Dependencies: mbed Chainable_RGB_LED DigitDisplay LoRaWAN-lib SX1276Lib
For a detailed description of the LoRaWAN operations, please visit the MBED dedicated page at https://developer.mbed.org/teams/Semtech/code/LoRaWAN-demo-76/
Revision 3:de1dcfbe175a, committed 2016-07-05
- Comitter:
- mluis
- Date:
- Tue Jul 05 15:02:26 2016 +0000
- Parent:
- 2:347904ba0bb0
- Child:
- 4:312eeebb61e3
- Commit message:
- Synchronized example application with GitHub LoRaMac-node examples; Updated mbed and LoRaWAN-lib libraries
Changed in this revision
--- a/app/Comissioning.h Wed May 18 11:34:31 2016 +0000 +++ b/app/Comissioning.h Tue Jul 05 15:02:26 2016 +0000 @@ -6,14 +6,14 @@ (______/|_____)_|_|_| \__)_____)\____)_| |_| (C)2015 Semtech -Description: End device comissioning parameters +Description: End device commissioning parameters License: Revised BSD License, see LICENSE.TXT file include in the project Maintainer: Miguel Luis and Gregory Cristian */ -#ifndef __LORA_COMISSIONING_H__ -#define __LORA_COMISSIONING_H__ +#ifndef __LORA_COMMISSIONING_H__ +#define __LORA_COMMISSIONING_H__ /*! * When set to 1 the application uses the Over-the-Air activation procedure @@ -26,8 +26,6 @@ */ #define LORAWAN_PUBLIC_NETWORK true -#if( OVER_THE_AIR_ACTIVATION != 0 ) - /*! * IEEE Organizationally Unique Identifier ( OUI ) (big endian) */ @@ -48,8 +46,6 @@ */ #define LORAWAN_APPLICATION_KEY { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C } -#else - /*! * Current network ID */ @@ -70,6 +66,4 @@ */ #define LORAWAN_APPSKEY { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C } -#endif - -#endif // __LORA_COMISSIONING_H__ +#endif // __LORA_COMMISSIONING_H__
--- a/app/main.cpp Wed May 18 11:34:31 2016 +0000 +++ b/app/main.cpp Tue Jul 05 15:02:26 2016 +0000 @@ -21,10 +21,6 @@ #include "SerialDisplay.h" #include "DigitDisplay.h" #include "ChainableLED.h" -/*! - * Join requests trials duty cycle. - */ -#define OVER_THE_AIR_ACTIVATION_DUTYCYCLE 10000000 // 10 [s] value in us /*! * Defines the application data transmission duty cycle. 5s, value in [us]. @@ -97,13 +93,11 @@ #endif -#if( OVER_THE_AIR_ACTIVATION != 0 ) - static uint8_t DevEui[] = LORAWAN_DEVICE_EUI; static uint8_t AppEui[] = LORAWAN_APPLICATION_EUI; static uint8_t AppKey[] = LORAWAN_APPLICATION_KEY; -#else +#if( OVER_THE_AIR_ACTIVATION == 0 ) static uint8_t NwkSKey[] = LORAWAN_NWKSKEY; static uint8_t AppSKey[] = LORAWAN_APPSKEY; @@ -291,11 +285,10 @@ SerialDisplayUpdateDevAddr( DevAddr ); SerialDisplayUpdateKey( 12, NwkSKey ); SerialDisplayUpdateKey( 13, AppSKey ); -#else +#endif SerialDisplayUpdateEui( 5, DevEui ); SerialDisplayUpdateEui( 6, AppEui ); SerialDisplayUpdateKey( 7, AppKey ); -#endif mibReq.Type = MIB_NETWORK_JOINED; LoRaMacMibGetRequestConfirm( &mibReq ); @@ -542,6 +535,11 @@ LoRaMacUplinkStatus.Datarate = mcpsConfirm->Datarate; LoRaMacUplinkStatus.UplinkCounter = mcpsConfirm->UpLinkCounter; + // Switch LED 1 ON + Led1State = true; + Led1StateChanged = true; + TimerStart( &Led1Timer ); + UplinkStatusUpdated = true; } NextTx = true; @@ -720,6 +718,20 @@ LoRaMacMlmeRequest( &mlmeReq ); } break; + case 6: // (ix) + { + MlmeReq_t mlmeReq; + + mlmeReq.Type = MLME_JOIN; + + mlmeReq.Req.Join.DevEui = DevEui; + mlmeReq.Req.Join.AppEui = AppEui; + mlmeReq.Req.Join.AppKey = AppKey; + + LoRaMacMlmeRequest( &mlmeReq ); + DeviceState = DEVICE_STATE_SLEEP; + } + break; default: break; } @@ -753,6 +765,8 @@ { // Status is OK, node has joined the network IsNetworkJoinedStatusUpdate = true; + DeviceState = DEVICE_STATE_SEND; + NextTx = true; break; } case MLME_LINK_CHECK: @@ -790,6 +804,17 @@ LightMode = 0; // 0: manual, 1: automatic Buzzer = 0; // 0: OFF, 1: ON + SerialDisplayUpdateEui( 5, DevEui ); + SerialDisplayUpdateEui( 6, AppEui ); + SerialDisplayUpdateKey( 7, AppKey ); + +#if( OVER_THE_AIR_ACTIVATION == 0 ) + SerialDisplayUpdateNwkId( LORAWAN_NETWORK_ID ); + SerialDisplayUpdateDevAddr( DevAddr ); + SerialDisplayUpdateKey( 12, NwkSKey ); + SerialDisplayUpdateKey( 13, AppSKey ); +#endif + DeviceState = DEVICE_STATE_INIT; while( 1 ) @@ -867,6 +892,10 @@ LoRaMacChannelAdd( 7, ( ChannelParams_t )LC8 ); LoRaMacChannelAdd( 8, ( ChannelParams_t )LC9 ); LoRaMacChannelAdd( 9, ( ChannelParams_t )LC10 ); + + mibReq.Type = MIB_RX2_CHANNEL; + mibReq.Param.Rx2Channel = ( Rx2ChannelParams_t ){ 869525000, DR_3 }; + LoRaMacMibSetRequestConfirm( &mibReq ); #endif #endif @@ -894,15 +923,7 @@ { LoRaMacMlmeRequest( &mlmeReq ); } - - SerialDisplayUpdateEui( 5, DevEui ); - SerialDisplayUpdateEui( 6, AppEui ); - SerialDisplayUpdateKey( 7, AppKey ); - - // Schedule next packet transmission - TxDutyCycleTime = OVER_THE_AIR_ACTIVATION_DUTYCYCLE; - DeviceState = DEVICE_STATE_CYCLE; - + DeviceState = DEVICE_STATE_SLEEP; #else mibReq.Type = MIB_NET_ID; mibReq.Param.NetID = LORAWAN_NETWORK_ID; @@ -924,11 +945,6 @@ mibReq.Param.IsNetworkJoined = true; LoRaMacMibSetRequestConfirm( &mibReq ); - SerialDisplayUpdateNwkId( LORAWAN_NETWORK_ID ); - SerialDisplayUpdateDevAddr( DevAddr ); - SerialDisplayUpdateKey( 12, NwkSKey ); - SerialDisplayUpdateKey( 13, AppSKey ); - DeviceState = DEVICE_STATE_SEND; #endif IsNetworkJoinedStatusUpdate = true; @@ -943,11 +959,6 @@ PrepareTxFrame( AppPort ); NextTx = SendFrame( ); - - // Switch LED 1 ON - Led1State = true; - Led1StateChanged = true; - TimerStart( &Led1Timer ); } if( ComplianceTest.Running == true ) {
--- a/mac/LoRaWAN-lib.lib Wed May 18 11:34:31 2016 +0000 +++ b/mac/LoRaWAN-lib.lib Tue Jul 05 15:02:26 2016 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/Semtech/code/LoRaWAN-lib/#d7a34ded7c87 +http://developer.mbed.org/teams/Semtech/code/LoRaWAN-lib/#c16969e0f70f
--- a/mbed.bld Wed May 18 11:34:31 2016 +0000 +++ b/mbed.bld Tue Jul 05 15:02:26 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/7c328cabac7e \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file
--- a/system/timer.cpp Wed May 18 11:34:31 2016 +0000 +++ b/system/timer.cpp Tue Jul 05 15:02:26 2016 +0000 @@ -17,7 +17,7 @@ Timer TimeCounter; Ticker LoadTimeCounter; -volatile uint32_t CurrentTime = 0; +volatile uint64_t CurrentTime = 0; void TimerResetTimeCounter( void ) {
--- a/system/timer.h Wed May 18 11:34:31 2016 +0000 +++ b/system/timer.h Tue Jul 05 15:02:26 2016 +0000 @@ -22,7 +22,7 @@ */ typedef struct TimerEvent_s { - uint32_t value; + uint64_t value; void ( *Callback )( void ); Ticker Timer; }TimerEvent_t; @@ -31,7 +31,7 @@ * \brief Timer time variable definition */ #ifndef TimerTime_t -typedef uint32_t TimerTime_t; +typedef uint64_t TimerTime_t; #endif /*!