Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed TimerGetElapsedTime race conditions #602

Merged
merged 1 commit into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/mac/region/RegionAS923.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,8 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_
NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 );
}

if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
if( nextChanParams->AggrTimeOff <= elapsed )
{
// Reset Aggregated time off
*aggregatedTimeOff = 0;
Expand All @@ -933,7 +934,7 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_
else
{
delayTx++;
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
nextTxDelay = nextChanParams->AggrTimeOff - elapsed;
}

if( nbEnabledChannels > 0 )
Expand Down
5 changes: 3 additions & 2 deletions src/mac/region/RegionAU915.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,8 @@ LoRaMacStatus_t RegionAU915NextChannel( NextChanParams_t* nextChanParams, uint8_
}
}

if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
if( nextChanParams->AggrTimeOff <= elapsed )
{
// Reset Aggregated time off
*aggregatedTimeOff = 0;
Expand All @@ -933,7 +934,7 @@ LoRaMacStatus_t RegionAU915NextChannel( NextChanParams_t* nextChanParams, uint8_
else
{
delayTx++;
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
nextTxDelay = nextChanParams->AggrTimeOff - elapsed;
}

if( nbEnabledChannels > 0 )
Expand Down
5 changes: 3 additions & 2 deletions src/mac/region/RegionCN470.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,8 @@ LoRaMacStatus_t RegionCN470NextChannel( NextChanParams_t* nextChanParams, uint8_
NvmCtx.ChannelsMask[5] = 0xFFFF;
}

if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
if( nextChanParams->AggrTimeOff <= elapsed )
{
// Reset Aggregated time off
*aggregatedTimeOff = 0;
Expand All @@ -750,7 +751,7 @@ LoRaMacStatus_t RegionCN470NextChannel( NextChanParams_t* nextChanParams, uint8_
else
{
delayTx++;
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
nextTxDelay = nextChanParams->AggrTimeOff - elapsed;
}

if( nbEnabledChannels > 0 )
Expand Down
5 changes: 3 additions & 2 deletions src/mac/region/RegionCN779.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,8 @@ LoRaMacStatus_t RegionCN779NextChannel( NextChanParams_t* nextChanParams, uint8_
NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
}

if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
if( nextChanParams->AggrTimeOff <= elapsed )
{
// Reset Aggregated time off
*aggregatedTimeOff = 0;
Expand All @@ -876,7 +877,7 @@ LoRaMacStatus_t RegionCN779NextChannel( NextChanParams_t* nextChanParams, uint8_
else
{
delayTx++;
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
nextTxDelay = nextChanParams->AggrTimeOff - elapsed;
}

if( nbEnabledChannels > 0 )
Expand Down
6 changes: 3 additions & 3 deletions src/mac/region/RegionCommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ TimerTime_t RegionCommonUpdateBandTimeOff( bool joined, bool dutyCycle, Band_t*
{
if( dutyCycle == true )
{
if( bands[i].TimeOff <= TimerGetElapsedTime( bands[i].LastTxDoneTime ) )
TimerTime_t elapsed = TimerGetElapsedTime( bands[i].LastTxDoneTime );
if( bands[i].TimeOff <= elapsed )
{
bands[i].TimeOff = 0;
}
if( bands[i].TimeOff != 0 )
{
nextTxDelay = MIN( bands[i].TimeOff - TimerGetElapsedTime( bands[i].LastTxDoneTime ),
nextTxDelay );
nextTxDelay = MIN( bands[i].TimeOff - elapsed, nextTxDelay );
}
}
else
Expand Down
5 changes: 3 additions & 2 deletions src/mac/region/RegionEU433.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,8 @@ LoRaMacStatus_t RegionEU433NextChannel( NextChanParams_t* nextChanParams, uint8_
NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
}

if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
if( nextChanParams->AggrTimeOff <= elapsed )
{
// Reset Aggregated time off
*aggregatedTimeOff = 0;
Expand All @@ -876,7 +877,7 @@ LoRaMacStatus_t RegionEU433NextChannel( NextChanParams_t* nextChanParams, uint8_
else
{
delayTx++;
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
nextTxDelay = nextChanParams->AggrTimeOff - elapsed;
}

if( nbEnabledChannels > 0 )
Expand Down
5 changes: 3 additions & 2 deletions src/mac/region/RegionEU868.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,8 @@ LoRaMacStatus_t RegionEU868NextChannel( NextChanParams_t* nextChanParams, uint8_
NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
}

if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
if( nextChanParams->AggrTimeOff <= elapsed )
{
// Reset Aggregated time off
*aggregatedTimeOff = 0;
Expand All @@ -908,7 +909,7 @@ LoRaMacStatus_t RegionEU868NextChannel( NextChanParams_t* nextChanParams, uint8_
else
{
delayTx++;
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
nextTxDelay = nextChanParams->AggrTimeOff - elapsed;
}

if( nbEnabledChannels > 0 )
Expand Down
5 changes: 3 additions & 2 deletions src/mac/region/RegionIN865.c
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,8 @@ LoRaMacStatus_t RegionIN865NextChannel( NextChanParams_t* nextChanParams, uint8_
NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
}

if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
if( nextChanParams->AggrTimeOff <= elapsed )
{
// Reset Aggregated time off
*aggregatedTimeOff = 0;
Expand All @@ -901,7 +902,7 @@ LoRaMacStatus_t RegionIN865NextChannel( NextChanParams_t* nextChanParams, uint8_
else
{
delayTx++;
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
nextTxDelay = nextChanParams->AggrTimeOff - elapsed;
}

if( nbEnabledChannels > 0 )
Expand Down
5 changes: 3 additions & 2 deletions src/mac/region/RegionKR920.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,8 @@ LoRaMacStatus_t RegionKR920NextChannel( NextChanParams_t* nextChanParams, uint8_
NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
}

if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
if( nextChanParams->AggrTimeOff <= elapsed )
{
// Reset Aggregated time off
*aggregatedTimeOff = 0;
Expand All @@ -870,7 +871,7 @@ LoRaMacStatus_t RegionKR920NextChannel( NextChanParams_t* nextChanParams, uint8_
else
{
delayTx++;
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
nextTxDelay = nextChanParams->AggrTimeOff - elapsed;
}

if( nbEnabledChannels > 0 )
Expand Down
5 changes: 3 additions & 2 deletions src/mac/region/RegionRU864.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,8 @@ LoRaMacStatus_t RegionRU864NextChannel( NextChanParams_t* nextChanParams, uint8_
NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 );
}

if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
if( nextChanParams->AggrTimeOff <= elapsed )
{
// Reset Aggregated time off
*aggregatedTimeOff = 0;
Expand All @@ -867,7 +868,7 @@ LoRaMacStatus_t RegionRU864NextChannel( NextChanParams_t* nextChanParams, uint8_
else
{
delayTx++;
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
nextTxDelay = nextChanParams->AggrTimeOff - elapsed;
}

if( nbEnabledChannels > 0 )
Expand Down
5 changes: 3 additions & 2 deletions src/mac/region/RegionUS915.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,8 @@ LoRaMacStatus_t RegionUS915NextChannel( NextChanParams_t* nextChanParams, uint8_
}
}

if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
if( nextChanParams->AggrTimeOff <= elapsed )
{
// Reset Aggregated time off
*aggregatedTimeOff = 0;
Expand All @@ -1025,7 +1026,7 @@ LoRaMacStatus_t RegionUS915NextChannel( NextChanParams_t* nextChanParams, uint8_
else
{
delayTx++;
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
nextTxDelay = nextChanParams->AggrTimeOff - elapsed;
}

if( nbEnabledChannels > 0 )
Expand Down