Skip to content

Commit fbb6a97

Browse files
committed
Issue #771 - Process received packet only if there is no CRC error.
1 parent a2057f0 commit fbb6a97

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

src/radio/sx126x/radio.c

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,39 +1102,41 @@ void RadioIrqProcess( void )
11021102

11031103
if( ( irqRegs & IRQ_RX_DONE ) == IRQ_RX_DONE )
11041104
{
1105-
uint8_t size;
1106-
1107-
TimerStop( &RxTimeoutTimer );
1108-
if( RxContinuous == false )
1105+
if( ( irqRegs & IRQ_CRC_ERROR ) == IRQ_CRC_ERROR )
11091106
{
1110-
//!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
1111-
SX126xSetOperatingMode( MODE_STDBY_RC );
1112-
1113-
// WORKAROUND - Implicit Header Mode Timeout Behavior, see DS_SX1261-2_V1.2 datasheet chapter 15.3
1114-
// RegRtcControl = @address 0x0902
1115-
SX126xWriteRegister( 0x0902, 0x00 );
1116-
// RegEventMask = @address 0x0944
1117-
SX126xWriteRegister( 0x0944, SX126xReadRegister( 0x0944 ) | ( 1 << 1 ) );
1118-
// WORKAROUND END
1107+
if( RxContinuous == false )
1108+
{
1109+
//!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
1110+
SX126xSetOperatingMode( MODE_STDBY_RC );
1111+
}
1112+
if( ( RadioEvents != NULL ) && ( RadioEvents->RxError ) )
1113+
{
1114+
RadioEvents->RxError( );
1115+
}
11191116
}
1120-
SX126xGetPayload( RadioRxPayload, &size , 255 );
1121-
SX126xGetPacketStatus( &RadioPktStatus );
1122-
if( ( RadioEvents != NULL ) && ( RadioEvents->RxDone != NULL ) )
1117+
else
11231118
{
1124-
RadioEvents->RxDone( RadioRxPayload, size, RadioPktStatus.Params.LoRa.RssiPkt, RadioPktStatus.Params.LoRa.SnrPkt );
1125-
}
1126-
}
1119+
uint8_t size;
11271120

1128-
if( ( irqRegs & IRQ_CRC_ERROR ) == IRQ_CRC_ERROR )
1129-
{
1130-
if( RxContinuous == false )
1131-
{
1132-
//!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
1133-
SX126xSetOperatingMode( MODE_STDBY_RC );
1134-
}
1135-
if( ( RadioEvents != NULL ) && ( RadioEvents->RxError ) )
1136-
{
1137-
RadioEvents->RxError( );
1121+
TimerStop( &RxTimeoutTimer );
1122+
if( RxContinuous == false )
1123+
{
1124+
//!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
1125+
SX126xSetOperatingMode( MODE_STDBY_RC );
1126+
1127+
// WORKAROUND - Implicit Header Mode Timeout Behavior, see DS_SX1261-2_V1.2 datasheet chapter 15.3
1128+
// RegRtcControl = @address 0x0902
1129+
SX126xWriteRegister( 0x0902, 0x00 );
1130+
// RegEventMask = @address 0x0944
1131+
SX126xWriteRegister( 0x0944, SX126xReadRegister( 0x0944 ) | ( 1 << 1 ) );
1132+
// WORKAROUND END
1133+
}
1134+
SX126xGetPayload( RadioRxPayload, &size , 255 );
1135+
SX126xGetPacketStatus( &RadioPktStatus );
1136+
if( ( RadioEvents != NULL ) && ( RadioEvents->RxDone != NULL ) )
1137+
{
1138+
RadioEvents->RxDone( RadioRxPayload, size, RadioPktStatus.Params.LoRa.RssiPkt, RadioPktStatus.Params.LoRa.SnrPkt );
1139+
}
11381140
}
11391141
}
11401142

0 commit comments

Comments
 (0)