mQ Branch for NA mote testing
Dependencies: LoRaWAN-lib SX1272Lib-mQ lib_gps lib_mma8451q lib_mpl3115a2 mbed
Fork of LoRaWAN-NAMote72-Application-Demo by
Diff: app/LoRaDeviceStateProc.cpp
- Revision:
- 18:18408c3c2d0c
- Parent:
- 0:69f2e28d12c1
--- a/app/LoRaDeviceStateProc.cpp Sun Apr 16 23:12:47 2017 +0000 +++ b/app/LoRaDeviceStateProc.cpp Mon Apr 24 13:47:27 2017 +0000 @@ -22,6 +22,8 @@ sLoRaMacDownlinkStatus LoRaMacDownlinkStatus; +sLoRaMacJoinStatus LoRaMacJoinStatus; + LoRaMacPrimitives_t LoRaPrimitives; LoRaMacCallback_t LoRaCallbacks; @@ -30,7 +32,6 @@ MlmeReq_t mlmeReq; - /*! * \brief Function executed on TxNextPacket Timeout event */ @@ -48,13 +49,13 @@ { if( mibReq.Param.IsNetworkJoined == true ) { - DeviceState = DEVICE_STATE_SEND; + DeviceState = DEVICE_STATE_SEND; + NextTx = true; } else { DeviceState = DEVICE_STATE_JOIN; } - NextTx = true; } } @@ -76,40 +77,50 @@ LoRaMibReq.Param.EnablePublicNetwork = LORAWAN_PUBLIC_NETWORK; LoRaMacMibSetRequestConfirm( &LoRaMibReq ); + LoRaMibReq.Type = MIB_CHANNELS_DEFAULT_TX_POWER; + LoRaMibReq.Param.ChannelsDefaultTxPower = LORAWAN_TX_POWER; + LoRaMacMibSetRequestConfirm( &LoRaMibReq ); + LoRaMibReq.Type = MIB_CHANNELS_TX_POWER; LoRaMibReq.Param.ChannelsTxPower = LORAWAN_TX_POWER; LoRaMacMibSetRequestConfirm( &LoRaMibReq ); LoRaMacDownlinkStatus.DownlinkCounter = 0; + + LoRaMacJoinStatus.LastDatarate = -1; } void DeviceJoinUpdate( void ) { LoRaMibReq.Type = MIB_NETWORK_JOINED; - LoRaMacMibGetRequestConfirm( &LoRaMibReq ); + LoRaMacMibGetRequestConfirm( &LoRaMibReq ); } void DeviceJoin( void ) { -#if( OVER_THE_AIR_ACTIVATION != 0 ) +#if( OVER_THE_AIR_ACTIVATION != 0 ) + Otaa = true; mlmeReq.Type = MLME_JOIN; - mlmeReq.Req.Join.DevEui = DevEui; mlmeReq.Req.Join.AppEui = AppEui; mlmeReq.Req.Join.AppKey = AppKey; + mlmeReq.Req.Join.NbTrials = 3; if( NextTx == true ) { LoRaMacMlmeRequest( &mlmeReq ); } +#else + Otaa = false; -#else // Choose a random device address if not already defined in Config.h if( DevAddr == 0 ) { // Random seed initialization srand1( BoardGetRandomSeed( ) ); + + // Choose a random device address DevAddr = randr( 0, 0x01FFFFFF ); } @@ -132,7 +143,6 @@ LoRaMibReq.Type = MIB_NETWORK_JOINED; LoRaMibReq.Param.IsNetworkJoined = true; LoRaMacMibSetRequestConfirm( &LoRaMibReq ); - #endif } @@ -158,7 +168,7 @@ if( port == 224 ) { - RunComplianceTest( ); + RunComplianceTest( ); } else { @@ -187,7 +197,7 @@ LoRaMacUplinkStatus.Acked = false; LoRaMacUplinkStatus.Port = 0; LoRaMacUplinkStatus.Buffer = NULL; - LoRaMacUplinkStatus.BufferSize = 0; + LoRaMacUplinkStatus.BufferSize = 0; } else { @@ -222,4 +232,4 @@ return false; } return true; -} \ No newline at end of file +}