diff --git a/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.c b/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.c index f279972..d46efc4 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.c @@ -329,6 +329,19 @@ typedef struct sLoRaMacCtx * Buffer containing the MAC layer commands */ uint8_t MacCommandsBuffer[LORA_MAC_COMMAND_MAX_LENGTH]; + /* + * Stores the reference time at at 1st JoinReq or ReJoinReq. + * + * \remark Used for the BACKOFF_DC computation. + */ + SysTime_t TxBackoffRefTime; + /* + * Indicates if \ref TxBackoffRefTime must be initialized or not. + * \ref TxBackoffRefTime must be initialized for 1st JoinReq or RejoinReq event. + * + * \remark Used for the BACKOFF_DC computation. + */ + bool IsFirstJoinReqTx; }LoRaMacCtx_t; /*! @@ -1076,7 +1089,7 @@ static void ProcessRadioTxDone( void ) // Update last tx done time for the current channel txDone.Channel = MacCtx.Channel; txDone.LastTxDoneTime = TxDoneParams.CurTime; - txDone.ElapsedTimeSinceStartUp = SysTimeSub( SysTimeGetMcuTime( ), Nvm.MacGroup2.InitializationTime ); + txDone.ElapsedTimeSinceTxBackoffRefTime = SysTimeSub( SysTimeGetMcuTime( ), MacCtx.TxBackoffRefTime ); txDone.LastTxAirTime = MacCtx.TxTimeOnAir; txDone.Joined = true; if( Nvm.MacGroup2.NetworkActivation == ACTIVATION_TYPE_NONE ) @@ -1398,6 +1411,9 @@ static void ProcessRadioRxDone( void ) ResetMacParameters( true ); } #endif /* LORAMAC_VERSION */ + // Restarts the retransmission backoff algorithm by indicating that the next JoinReq or ReJoinReq + // is the first one. + MacCtx.IsFirstJoinReqTx = true; } else { @@ -3471,6 +3487,13 @@ static LoRaMacStatus_t SendReJoinReq( JoinReqIdentifier_t joinReqType ) break; } + if( MacCtx.IsFirstJoinReqTx == true ) + { + MacCtx.IsFirstJoinReqTx = false; + // Store the current time as reference time for the retransmission backoff algorithm + MacCtx.TxBackoffRefTime = SysTimeGetMcuTime( ); + } + // Schedule frame status = ScheduleTx( allowDelayedTx ); return status; @@ -3618,7 +3641,7 @@ static LoRaMacStatus_t ScheduleTx( bool allowDelayedTx ) nextChan.AggrTimeOff = Nvm.MacGroup1.AggregatedTimeOff; nextChan.Datarate = Nvm.MacGroup1.ChannelsDatarate; nextChan.DutyCycleEnabled = Nvm.MacGroup2.DutyCycleOn; - nextChan.ElapsedTimeSinceStartUp = SysTimeSub( SysTimeGetMcuTime( ), Nvm.MacGroup2.InitializationTime ); + nextChan.ElapsedTimeSinceTxBackoffRefTime = SysTimeSub( SysTimeGetMcuTime( ), MacCtx.TxBackoffRefTime ); nextChan.LastAggrTx = Nvm.MacGroup1.LastTxDoneTime; nextChan.LastTxIsJoinRequest = false; nextChan.Joined = true; @@ -4698,8 +4721,8 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t* primitives, LoRaMacC TimerInit( &MacCtx.ForceRejoinReqCycleTimer, OnForceRejoinReqCycleTimerEvent ); #endif /* LORAMAC_VERSION */ - // Store the current initialization time - Nvm.MacGroup2.InitializationTime = SysTimeGetMcuTime( ); + // At stack initialization no JoinReq has been transmitted yet + MacCtx.IsFirstJoinReqTx = true; #if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) // Initialize MAC radio events diff --git a/src/STM32CubeWL/LoRaWAN/Mac/LoRaMacInterfaces.h b/src/STM32CubeWL/LoRaWAN/Mac/LoRaMacInterfaces.h index a49ce7d..14c60e9 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/LoRaMacInterfaces.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/LoRaMacInterfaces.h @@ -1125,10 +1125,11 @@ typedef struct sLoRaMacNvmDataGroup2 * Aggregated duty cycle management */ uint16_t AggregatedDCycle; - /*! + /*! * Stores the time at LoRaMac initialization. + * This value is no more used as defined by the LoRaWAN Specification v1.0.4. * - * \remark Used for the BACKOFF_DC computation. + * \remark Taken in the structure only for Backward compatibility. */ SysTime_t InitializationTime; /*! diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.h index 829bf19..045e371 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.h @@ -466,7 +466,7 @@ typedef struct sSetBandTxDoneParams /*! * Elapsed time since initialization. */ - SysTime_t ElapsedTimeSinceStartUp; + SysTime_t ElapsedTimeSinceTxBackoffRefTime; }SetBandTxDoneParams_t; /*! @@ -814,7 +814,7 @@ typedef struct sNextChanParams /*! * Elapsed time since the start of the node. */ - SysTime_t ElapsedTimeSinceStartUp; + SysTime_t ElapsedTimeSinceTxBackoffRefTime; /*! * Joined Set to true, if the last uplink was a join request */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.c index 1792c19..249d829 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.c @@ -99,7 +99,7 @@ #define AS923_MIN_RF_FREQUENCY 915000000 #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) #define AS923_MAX_RF_FREQUENCY 921000000 -#else +#else #define AS923_MAX_RF_FREQUENCY 928000000 #endif @@ -169,9 +169,6 @@ #undef AS923_RX_MAX_DATARATE #define AS923_RX_MAX_DATARATE DR_5 -#undef AS923_DEFAULT_MAX_EIRP -#define AS923_DEFAULT_MAX_EIRP 13.0f - /*! * STD-T108 Ver1.4 does not require dwell-time enforcement when using LBT on channels 28 to 38 */ @@ -202,9 +199,6 @@ #undef AS923_RX_MAX_DATARATE #define AS923_RX_MAX_DATARATE DR_5 -#undef AS923_DEFAULT_MAX_EIRP -#define AS923_DEFAULT_MAX_EIRP 13.0f - /*! * STD-T108 Ver1.4 does not require dwell-time enforcement when using DC on channels 28 to 38 */ @@ -217,19 +211,19 @@ #undef AS923_DUTY_CYCLE_ENABLED #define AS923_DUTY_CYCLE_ENABLED 1 -#elif ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH37_CH61_LBT_DC ) +#elif ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH33_CH61_LBT_DC ) /* - * STD-T108 Ver1.4 allows the use of channels 37 to 61 with LBT and DC. + * STD-T108 Ver1.4 allows the use of channels 33 to 61 with LBT and DC. * However dwell time enforcement must be enabled */ -// Channel plan CHANNEL_PLAN_GROUP_AS923_1_JP_CH37_CH61_LBT_DC +// Channel plan CHANNEL_PLAN_GROUP_AS923_1_JP_CH33_CH61_LBT_DC #define REGION_AS923_FREQ_OFFSET 0 /*! - * Restrict AS923 frequencies to channels 37 to 61 + * Restrict AS923 frequencies to channels 33 to 61 * Center frequencies 922.4 MHz to 928.0 MHz @ 200 kHz max bandwidth */ #define AS923_MIN_RF_FREQUENCY 922400000 @@ -241,9 +235,6 @@ #undef AS923_RX_MAX_DATARATE #define AS923_RX_MAX_DATARATE DR_5 -#undef AS923_DEFAULT_MAX_EIRP -#define AS923_DEFAULT_MAX_EIRP 13.0f - /*! * Enable duty cycle enforcement */ @@ -251,7 +242,7 @@ #define AS923_DUTY_CYCLE_ENABLED 1 /*! - * STD-T108 Ver1.4 requires a carrier sense time of at least 128 us on channels 37 to 61 + * STD-T108 Ver1.4 requires a carrier sense time of at least 128 us on channels 33 to 61 */ #undef AS923_CARRIER_SENSE_TIME #define AS923_CARRIER_SENSE_TIME 1 @@ -562,10 +553,10 @@ void RegionAS923SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if defined( REGION_AS923 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #endif /* REGION_VERSION */ #endif /* REGION_AS923 */ } @@ -617,7 +608,7 @@ void RegionAS923InitDefaults( InitDefaultsParams_t* params ) #if ( ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP ) || \ ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_LBT ) || \ - ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH37_CH61_LBT_DC ) ) + ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH33_CH61_LBT_DC ) ) RegionNvmGroup2->RssiFreeThreshold = AS923_RSSI_FREE_TH; RegionNvmGroup2->CarrierSenseTime = AS923_CARRIER_SENSE_TIME; #endif @@ -1023,7 +1014,6 @@ uint8_t RegionAS923RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq ) { uint8_t status = 0x07; #if defined( REGION_AS923 ) - // Verify radio frequency if( VerifyRfFreq( rxParamSetupReq->Frequency ) == false ) { @@ -1181,7 +1171,7 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.DutyCycleEnabled = nextChanParams->DutyCycleEnabled; identifyChannelsParam.MaxBands = AS923_MAX_NB_BANDS; - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); @@ -1194,7 +1184,7 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_ { #if (( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP ) || \ ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_LBT ) || \ - ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH37_CH61_LBT_DC ) ) + ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH33_CH61_LBT_DC ) ) // Executes the LBT algorithm when operating in Japan uint8_t channelNext = 0; diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.h index 0cdaf86..54d0141 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.h @@ -99,10 +99,10 @@ extern "C" #define CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_DC 6 /*! - * Channel plan group AS923-1 for Japan - channels 37 to 61 Listen Before Talk + Duty Cycle + * Channel plan group AS923-1 for Japan - channels 33 to 61 Listen Before Talk + Duty Cycle * AS923_FREQ_OFFSET = 0 */ -#define CHANNEL_PLAN_GROUP_AS923_1_JP_CH37_CH61_LBT_DC 7 +#define CHANNEL_PLAN_GROUP_AS923_1_JP_CH33_CH61_LBT_DC 7 #endif /*! diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.c index e569fd4..e9d7962 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.c @@ -376,10 +376,10 @@ void RegionAU915SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if defined( REGION_AU915 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #endif /* REGION_VERSION */ #endif /* REGION_AU915 */ } @@ -976,7 +976,7 @@ LoRaMacStatus_t RegionAU915NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.DutyCycleEnabled = nextChanParams->DutyCycleEnabled; identifyChannelsParam.MaxBands = AU915_MAX_NB_BANDS; - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.c index caf1cc1..59b6196 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.c @@ -663,10 +663,10 @@ void RegionCN470SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if defined( REGION_CN470 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #endif /* REGION_VERSION */ #endif /* REGION_CN470 */ } @@ -1321,7 +1321,7 @@ LoRaMacStatus_t RegionCN470NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.DutyCycleEnabled = nextChanParams->DutyCycleEnabled; identifyChannelsParam.MaxBands = CN470_MAX_NB_BANDS; - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.c index ffc32b4..c02142b 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.c @@ -315,10 +315,10 @@ void RegionCN779SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if defined( REGION_CN779 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #endif /* REGION_VERSION */ #endif /* REGION_CN779 */ } @@ -905,7 +905,7 @@ LoRaMacStatus_t RegionCN779NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.DutyCycleEnabled = nextChanParams->DutyCycleEnabled; identifyChannelsParam.MaxBands = CN779_MAX_NB_BANDS; - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.c index 93f76ef..17ea47a 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.c @@ -65,7 +65,7 @@ * defined duty-cycle restrictions. In order to ensure that these restrictions never get violated we changed the * default duty cycle observation time period to 1/2 hour (1800000 ms). */ -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) #define DUTY_CYCLE_TIME_PERIOD 3600000 #else #define DUTY_CYCLE_TIME_PERIOD 1800000 @@ -107,7 +107,7 @@ static uint16_t GetDutyCycle( Band_t* band, bool joined, SysTime_t elapsedTimeSi if( joined == false ) { -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) uint16_t joinDutyCycle = BACKOFF_DC_1_HOUR; #else uint16_t joinDutyCycle = BACKOFF_DC_24_HOURS; @@ -151,7 +151,7 @@ static uint16_t SetMaxTimeCredits( Band_t* band, bool joined, SysTime_t elapsedT if( joined == false ) { #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) - if( elapsedTimeSinceStartup.Seconds < BACKOFF_DUTY_CYCLE_1_HOUR_IN_S ) + if( elapsedTimeSinceStartup.Seconds < BACKOFF_DUTY_CYCLE_1_HOUR_IN_S ) { maxCredits = DUTY_CYCLE_TIME_PERIOD; } @@ -164,8 +164,8 @@ static uint16_t SetMaxTimeCredits( Band_t* band, bool joined, SysTime_t elapsedT maxCredits = DUTY_CYCLE_TIME_PERIOD_JOIN_BACKOFF_24H; } #else - TimerTime_t elapsedTime = SysTimeToMs( elapsedTimeSinceStartup ); - SysTime_t timeDiff = { 0 }; + TimerTime_t elapsedTime = SysTimeToMs( elapsedTimeSinceStartup ); + SysTime_t timeDiff = { 0 }; if( dutyCycle == BACKOFF_DC_1_HOUR ) { maxCredits = DUTY_CYCLE_TIME_PERIOD; @@ -218,7 +218,7 @@ static uint16_t SetMaxTimeCredits( Band_t* band, bool joined, SysTime_t elapsedT { band->TimeCredits = maxCredits; } -#endif +#endif // Setup the maximum allowed credits. We can assign them // safely all the time. @@ -228,7 +228,7 @@ static uint16_t SetMaxTimeCredits( Band_t* band, bool joined, SysTime_t elapsedT } -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) static uint16_t UpdateTimeCredits( Band_t* band, bool joined, bool dutyCycleEnabled, bool lastTxIsJoinRequest, SysTime_t elapsedTimeSinceStartup, TimerTime_t currentTime, TimerTime_t lastBandUpdateTime ) @@ -456,7 +456,7 @@ TimerTime_t RegionCommonUpdateBandTimeOff( bool joined, Band_t* bands, // We calculate the minTimeToWait among the bands which are not // ready for transmission and which are potentially available // for a transmission in the future. -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) TimerTime_t observationTimeDiff = 0; if( bands[i].LastMaxCreditAssignTime >= elapsedTime ) { @@ -727,7 +727,7 @@ LoRaMacStatus_t RegionCommonIdentifyChannels( RegionCommonIdentifyChannelsParam_ identifyChannelsParam->MaxBands, identifyChannelsParam->DutyCycleEnabled, identifyChannelsParam->LastTxIsJoinRequest, - identifyChannelsParam->ElapsedTimeSinceStartUp, + identifyChannelsParam->ElapsedTimeSinceTxBackoffRefTime, identifyChannelsParam->ExpectedTimeOnAir ); RegionCommonCountNbOfEnabledChannels( identifyChannelsParam->CountNbOfEnabledChannelsParam, enabledChannels, diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.h index 2cb7ad0..6f6ffbf 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.h @@ -307,7 +307,7 @@ typedef struct sRegionCommonIdentifyChannelsParam /*! * Elapsed time since the start of the node. */ - SysTime_t ElapsedTimeSinceStartUp; + SysTime_t ElapsedTimeSinceTxBackoffRefTime; /*! * Joined Set to true, if the last uplink was a join request */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.c index 30e26ce..69f09bb 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.c @@ -315,10 +315,10 @@ void RegionEU433SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if defined( REGION_EU433 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #endif /* REGION_VERSION */ #endif /* REGION_EU433 */ } @@ -909,7 +909,7 @@ LoRaMacStatus_t RegionEU433NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.DutyCycleEnabled = nextChanParams->DutyCycleEnabled; identifyChannelsParam.MaxBands = EU433_MAX_NB_BANDS; - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.c index 6528cb8..2e564d4 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.c @@ -341,10 +341,10 @@ void RegionEU868SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if defined( REGION_EU868 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #endif /* REGION_VERSION */ #endif /* REGION_EU868 */ } @@ -945,7 +945,7 @@ LoRaMacStatus_t RegionEU868NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.DutyCycleEnabled = nextChanParams->DutyCycleEnabled; identifyChannelsParam.MaxBands = EU868_MAX_NB_BANDS; - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.c index f313302..6814509 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.c @@ -314,10 +314,10 @@ void RegionIN865SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if defined( REGION_IN865 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #endif /* REGION_VERSION */ #endif /* REGION_IN865 */ } @@ -931,7 +931,7 @@ LoRaMacStatus_t RegionIN865NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.DutyCycleEnabled = nextChanParams->DutyCycleEnabled; identifyChannelsParam.MaxBands = IN865_MAX_NB_BANDS; - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.c index 5aba9a9..923ed4a 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.c @@ -345,10 +345,10 @@ void RegionKR920SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if defined( REGION_KR920 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #endif /* REGION_VERSION */ #endif /* REGION_KR920 */ } @@ -921,7 +921,7 @@ LoRaMacStatus_t RegionKR920NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.DutyCycleEnabled = nextChanParams->DutyCycleEnabled; identifyChannelsParam.MaxBands = KR920_MAX_NB_BANDS; - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.c index e99cc3f..3a0596a 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.c @@ -317,10 +317,10 @@ void RegionRU864SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if defined( REGION_RU864 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #endif /* REGION_VERSION */ #endif /* REGION_RU864 */ @@ -911,7 +911,7 @@ LoRaMacStatus_t RegionRU864NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.DutyCycleEnabled = nextChanParams->DutyCycleEnabled; identifyChannelsParam.MaxBands = RU864_MAX_NB_BANDS; - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.c index ac05226..e567e58 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.c @@ -368,10 +368,10 @@ void RegionUS915SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if defined( REGION_US915 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], - txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); + txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceTxBackoffRefTime ); #endif /* REGION_VERSION */ #endif /* REGION_US915 */ } @@ -991,7 +991,7 @@ LoRaMacStatus_t RegionUS915NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.MaxBands = US915_MAX_NB_BANDS; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); @@ -999,7 +999,7 @@ LoRaMacStatus_t RegionUS915NextChannel( NextChanParams_t* nextChanParams, uint8_ #elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) identifyChannelsParam.CountNbOfEnabledChannelsParam = &countChannelsParams; - identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; + identifyChannelsParam.ElapsedTimeSinceTxBackoffRefTime = nextChanParams->ElapsedTimeSinceTxBackoffRefTime; identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest; identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); #endif /* REGION_VERSION */ diff --git a/src/STM32CubeWL/LoRaWAN/Release_Notes.html b/src/STM32CubeWL/LoRaWAN/Release_Notes.html index 0eda896..30160e5 100644 --- a/src/STM32CubeWL/LoRaWAN/Release_Notes.html +++ b/src/STM32CubeWL/LoRaWAN/Release_Notes.html @@ -6,13 +6,19 @@
Copyright © 2020 STMicroelectronics
+This Middleware provides the LoRaWAN Stack. This stack is based on the LoRaMac from Semtech/StackForce (see readme.md)
+This Middleware provides the LoRaWAN Stack. This stack is based on +the LoRaMac from Semtech/StackForce (see readme.md)
This driver is composed of 5 directories:
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None