Skip to content

Commit 5c75cda

Browse files
authored
Merge pull request #610 from thingsconnected/pullreq1.1
Make uses of TimerGetElapsedTime(t) aware of t==0 situation
2 parents cbde060 + 2cac96e commit 5c75cda

File tree

13 files changed

+20
-12
lines changed

13 files changed

+20
-12
lines changed

src/mac/region/RegionAS923.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_
918918
}
919919

920920
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
921-
if( nextChanParams->AggrTimeOff <= elapsed )
921+
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
922922
{
923923
// Reset Aggregated time off
924924
*aggregatedTimeOff = 0;

src/mac/region/RegionAU915.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ LoRaMacStatus_t RegionAU915NextChannel( NextChanParams_t* nextChanParams, uint8_
918918
}
919919

920920
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
921-
if( nextChanParams->AggrTimeOff <= elapsed )
921+
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
922922
{
923923
// Reset Aggregated time off
924924
*aggregatedTimeOff = 0;

src/mac/region/RegionCN470.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ LoRaMacStatus_t RegionCN470NextChannel( NextChanParams_t* nextChanParams, uint8_
735735
}
736736

737737
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
738-
if( nextChanParams->AggrTimeOff <= elapsed )
738+
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
739739
{
740740
// Reset Aggregated time off
741741
*aggregatedTimeOff = 0;

src/mac/region/RegionCN779.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ LoRaMacStatus_t RegionCN779NextChannel( NextChanParams_t* nextChanParams, uint8_
861861
}
862862

863863
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
864-
if( nextChanParams->AggrTimeOff <= elapsed )
864+
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
865865
{
866866
// Reset Aggregated time off
867867
*aggregatedTimeOff = 0;

src/mac/region/RegionCommon.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ TimerTime_t RegionCommonUpdateBandTimeOff( bool joined, bool dutyCycle, Band_t*
169169
{
170170
if( joined == false )
171171
{
172-
TimerTime_t txDoneTime = MAX( TimerGetElapsedTime( bands[i].LastJoinTxDoneTime ),
173-
( dutyCycle == true ) ? TimerGetElapsedTime( bands[i].LastTxDoneTime ) : 0 );
172+
TimerTime_t elapsedJoin = TimerGetElapsedTime( bands[i].LastJoinTxDoneTime );
173+
TimerTime_t elapsedTx = TimerGetElapsedTime( bands[i].LastTxDoneTime );
174+
TimerTime_t txDoneTime = MAX( elapsedJoin,
175+
( dutyCycle == true ) ? elapsedTx : 0 );
174176

175177
if( bands[i].TimeOff <= txDoneTime )
176178
{

src/mac/region/RegionEU433.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ LoRaMacStatus_t RegionEU433NextChannel( NextChanParams_t* nextChanParams, uint8_
861861
}
862862

863863
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
864-
if( nextChanParams->AggrTimeOff <= elapsed )
864+
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
865865
{
866866
// Reset Aggregated time off
867867
*aggregatedTimeOff = 0;

src/mac/region/RegionEU868.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ LoRaMacStatus_t RegionEU868NextChannel( NextChanParams_t* nextChanParams, uint8_
893893
}
894894

895895
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
896-
if( nextChanParams->AggrTimeOff <= elapsed )
896+
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
897897
{
898898
// Reset Aggregated time off
899899
*aggregatedTimeOff = 0;

src/mac/region/RegionIN865.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ LoRaMacStatus_t RegionIN865NextChannel( NextChanParams_t* nextChanParams, uint8_
886886
}
887887

888888
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
889-
if( nextChanParams->AggrTimeOff <= elapsed )
889+
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
890890
{
891891
// Reset Aggregated time off
892892
*aggregatedTimeOff = 0;

src/mac/region/RegionKR920.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ LoRaMacStatus_t RegionKR920NextChannel( NextChanParams_t* nextChanParams, uint8_
855855
}
856856

857857
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
858-
if( nextChanParams->AggrTimeOff <= elapsed )
858+
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
859859
{
860860
// Reset Aggregated time off
861861
*aggregatedTimeOff = 0;

src/mac/region/RegionRU864.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ LoRaMacStatus_t RegionRU864NextChannel( NextChanParams_t* nextChanParams, uint8_
852852
}
853853

854854
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
855-
if( nextChanParams->AggrTimeOff <= elapsed )
855+
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
856856
{
857857
// Reset Aggregated time off
858858
*aggregatedTimeOff = 0;

0 commit comments

Comments
 (0)