Skip to content

Commit 7ca6b33

Browse files
committed
[LoRaWAN] Move random's seed to session creation
1 parent 35e9c39 commit 7ca6b33

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/protocols/LoRaWAN/LoRaWAN.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,6 @@ void LoRaWANNode::clearSession() {
349349
// revert to default Class A
350350
this->lwClass = RADIOLIB_LORAWAN_CLASS_A;
351351

352-
// set a seed for the pseudo-rng using a truly random value from radio noise
353-
srand(this->phyLayer->random(INT32_MAX));
354-
355352
// reset all channels
356353
memset(this->channels, 0, sizeof(this->channels));
357354
memset(this->dynamicChannels, 0, sizeof(this->dynamicChannels));
@@ -365,7 +362,10 @@ void LoRaWANNode::clearSession() {
365362
this->sessionStatus = RADIOLIB_LORAWAN_SESSION_NONE;
366363
}
367364

368-
void LoRaWANNode::createSession() {
365+
void LoRaWANNode::createSession() {
366+
// set a seed for the pseudo-rng using a truly random value from radio noise
367+
srand(this->phyLayer->random(INT32_MAX));
368+
369369
// setup default channels
370370
if(this->band->bandType == RADIOLIB_LORAWAN_BAND_DYNAMIC) {
371371
for(int num = 0; num < 3; num++) {

0 commit comments

Comments
 (0)