Skip to content

Commit e5076e1

Browse files
committed
Issue #1349 - Fixed Rx windows timer handling
1 parent fed2bc5 commit e5076e1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/mac/LoRaMac.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,15 @@ static void ProcessRadioTxDone( void )
808808
{
809809
Radio.Sleep( );
810810
}
811+
811812
// Setup timers
812-
TimerSetValue( &MacCtx.RxWindowTimer1, MacCtx.RxWindow1Delay );
813+
CRITICAL_SECTION_BEGIN( );
814+
uint32_t offset = TimerGetCurrentTime( ) - TxDoneParams.CurTime;
815+
TimerSetValue( &MacCtx.RxWindowTimer1, MacCtx.RxWindow1Delay - offset );
813816
TimerStart( &MacCtx.RxWindowTimer1 );
814-
TimerSetValue( &MacCtx.RxWindowTimer2, MacCtx.RxWindow2Delay );
817+
TimerSetValue( &MacCtx.RxWindowTimer2, MacCtx.RxWindow2Delay - offset );
815818
TimerStart( &MacCtx.RxWindowTimer2 );
819+
CRITICAL_SECTION_END( );
816820

817821
if( MacCtx.NodeAckRequested == true )
818822
{

0 commit comments

Comments
 (0)