Skip to content

Commit b4d37f7

Browse files
author
Daniel Jäckle
committed
Update initialization to use the function ResetMacParameters.
1 parent b9d3aac commit b4d37f7

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

src/mac/LoRaMac.c

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,19 +3099,28 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacC
30993099
LoRaMacFlags.Value = 0;
31003100

31013101
LoRaMacDeviceClass = CLASS_A;
3102+
LoRaMacState = MAC_IDLE;
31023103

3103-
UpLinkCounter = 1;
3104-
DownLinkCounter = 0;
3105-
AdrAckCounter = 0;
31063104
JoinRequestTrials = 0;
3105+
RepeaterSupport = false;
31073106

3108-
MacCommandsBufferIndex = 0;
3109-
MacCommandsBufferToRepeatIndex = 0;
3107+
// Reset duty cycle times
3108+
AggregatedLastTxDoneTime = 0;
3109+
AggregatedTimeOff = 0;
3110+
3111+
// Duty cycle
3112+
#if defined( USE_BAND_433 )
3113+
DutyCycleOn = false;
3114+
#elif defined( USE_BAND_780 )
3115+
DutyCycleOn = false;
3116+
#elif defined( USE_BAND_868 )
3117+
DutyCycleOn = true;
3118+
#elif defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
3119+
DutyCycleOn = false;
3120+
#else
3121+
#error "Please define a frequency band in the compiler options."
3122+
#endif
31103123

3111-
RepeaterSupport = false;
3112-
IsRxWindowsEnabled = true;
3113-
IsLoRaMacNetworkJoined = false;
3114-
LoRaMacState = MAC_IDLE;
31153124
// Reset to defaults
31163125
LoRaMacParamsDefaults.ChannelsTxPower = LORAMAC_DEFAULT_TX_POWER;
31173126
LoRaMacParamsDefaults.ChannelsDatarate = LORAMAC_DEFAULT_DATARATE;
@@ -3169,26 +3178,9 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacC
31693178
}
31703179
#endif
31713180

3172-
ChannelsNbRepCounter = 0;
3173-
3174-
MaxDCycle = 0;
3175-
AggregatedDCycle = 1;
3176-
AggregatedLastTxDoneTime = 0;
3177-
AggregatedTimeOff = 0;
3178-
3179-
#if defined( USE_BAND_433 )
3180-
DutyCycleOn = false;
3181-
#elif defined( USE_BAND_780 )
3182-
DutyCycleOn = false;
3183-
#elif defined( USE_BAND_868 )
3184-
DutyCycleOn = true;
3185-
#elif defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
3186-
DutyCycleOn = false;
3187-
#else
3188-
#error "Please define a frequency band in the compiler options."
3189-
#endif
3190-
3181+
ResetMacParameters( );
31913182

3183+
// Initialize timers
31923184
TimerInit( &MacStateCheckTimer, OnMacStateCheckTimerEvent );
31933185
TimerSetValue( &MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT );
31943186

@@ -3208,9 +3200,6 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacC
32083200
// Random seed initialization
32093201
srand1( Radio.Random( ) );
32103202

3211-
// Initialize channel index.
3212-
Channel = LORA_MAX_NB_CHANNELS;
3213-
32143203
PublicNetwork = true;
32153204
SetPublicNetwork( PublicNetwork );
32163205
Radio.Sleep( );

0 commit comments

Comments
 (0)