Skip to content

Commit 8420020

Browse files
committed
LoRaMacFCntHandler: changed initialization order
The callback is assigned after resetting FCnt values in LoRaMacResetFCnts(), while LoRaMacResetFCnts() tries to invoke the callback using NvmCtxChanged(), which will either fail (no callback has been set before) or - in theory - call a callback which has been assigned before, which seems to lead to unexpected behavior. By reversing the statements all is fixed.
1 parent aa412a6 commit 8420020

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/mac/LoRaMacFCntHandler.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ static void NvmCtxChanged( void )
106106

107107
LoRaMacFCntHandlerStatus_t LoRaMacFCntHandlerInit( EventNvmCtxChanged fCntHandlerNvmCtxChanged )
108108
{
109-
// Initialize with default
110-
LoRaMacResetFCnts( );
111-
112109
// Assign callback
113110
FCntHandlerNvmCtxChanged = fCntHandlerNvmCtxChanged;
114111

112+
// Initialize with default
113+
LoRaMacResetFCnts( );
114+
115115
return LORAMAC_FCNT_HANDLER_SUCCESS;
116116
}
117117

0 commit comments

Comments
 (0)