Skip to content

Commit 4be8f75

Browse files
Daniel Jaecklemluis1
authored andcommitted
Relocate initialization of class b into the function ResetMacParameters.
1 parent 3f2d530 commit 4be8f75

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

src/mac/LoRaMac.c

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,6 +2634,9 @@ static void RemoveMacCommands( LoRaMacRxSlot_t rxSlot, LoRaMacFrameCtrl_t fCtrl,
26342634

26352635
static void ResetMacParameters( void )
26362636
{
2637+
LoRaMacClassBCallback_t classBCallbacks;
2638+
LoRaMacClassBParams_t classBParams;
2639+
26372640
MacCtx.NvmCtx->NetworkActivation = ACTIVATION_TYPE_NONE;
26382641

26392642
// ADR counter
@@ -2681,6 +2684,28 @@ static void ResetMacParameters( void )
26812684
MacCtx.RxWindowCConfig.RxContinuous = true;
26822685
MacCtx.RxWindowCConfig.RxSlot = RX_SLOT_WIN_CLASS_C;
26832686

2687+
// Initialize class b
2688+
// Apply callback
2689+
classBCallbacks.GetTemperatureLevel = NULL;
2690+
classBCallbacks.MacProcessNotify = NULL;
2691+
2692+
if( MacCtx.MacCallbacks != NULL )
2693+
{
2694+
classBCallbacks.GetTemperatureLevel = MacCtx.MacCallbacks->GetTemperatureLevel;
2695+
classBCallbacks.MacProcessNotify = MacCtx.MacCallbacks->MacProcessNotify;
2696+
}
2697+
2698+
// Must all be static. Don't use local references.
2699+
classBParams.MlmeIndication = &MacCtx.MlmeIndication;
2700+
classBParams.McpsIndication = &MacCtx.McpsIndication;
2701+
classBParams.MlmeConfirm = &MacCtx.MlmeConfirm;
2702+
classBParams.LoRaMacFlags = &MacCtx.MacFlags;
2703+
classBParams.LoRaMacDevAddr = &MacCtx.NvmCtx->DevAddr;
2704+
classBParams.LoRaMacRegion = &MacCtx.NvmCtx->Region;
2705+
classBParams.LoRaMacParams = &MacCtx.NvmCtx->MacParams;
2706+
classBParams.MulticastChannels = &MacCtx.NvmCtx->MulticastChannelList[0];
2707+
2708+
LoRaMacClassBInit( &classBParams, &classBCallbacks, &EventClassBNvmCtxChanged );
26842709
}
26852710

26862711
/*!
@@ -3200,8 +3225,6 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t* primitives, LoRaMacC
32003225
{
32013226
GetPhyParams_t getPhy;
32023227
PhyParam_t phyParam;
3203-
LoRaMacClassBCallback_t classBCallbacks;
3204-
LoRaMacClassBParams_t classBParams;
32053228

32063229
if( ( primitives == NULL ) ||
32073230
( callbacks == NULL ) )
@@ -3389,28 +3412,6 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t* primitives, LoRaMacC
33893412
Radio.SetPublicNetwork( MacCtx.NvmCtx->PublicNetwork );
33903413
Radio.Sleep( );
33913414

3392-
// Initialize class b
3393-
// Apply callback
3394-
classBCallbacks.GetTemperatureLevel = NULL;
3395-
classBCallbacks.MacProcessNotify = NULL;
3396-
if( callbacks != NULL )
3397-
{
3398-
classBCallbacks.GetTemperatureLevel = callbacks->GetTemperatureLevel;
3399-
classBCallbacks.MacProcessNotify = callbacks->MacProcessNotify;
3400-
}
3401-
3402-
// Must all be static. Don't use local references.
3403-
classBParams.MlmeIndication = &MacCtx.MlmeIndication;
3404-
classBParams.McpsIndication = &MacCtx.McpsIndication;
3405-
classBParams.MlmeConfirm = &MacCtx.MlmeConfirm;
3406-
classBParams.LoRaMacFlags = &MacCtx.MacFlags;
3407-
classBParams.LoRaMacDevAddr = &MacCtx.NvmCtx->DevAddr;
3408-
classBParams.LoRaMacRegion = &MacCtx.NvmCtx->Region;
3409-
classBParams.LoRaMacParams = &MacCtx.NvmCtx->MacParams;
3410-
classBParams.MulticastChannels = &MacCtx.NvmCtx->MulticastChannelList[0];
3411-
3412-
LoRaMacClassBInit( &classBParams, &classBCallbacks, &EventClassBNvmCtxChanged );
3413-
34143415
LoRaMacEnableRequests( LORAMAC_REQUEST_HANDLING_ON );
34153416

34163417
return LORAMAC_STATUS_OK;

0 commit comments

Comments
 (0)