Skip to content

Commit

Permalink
Fix #171: don't use ABP info for OTAA unless saved state is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
terrillmoore committed Jul 5, 2021
1 parent e9b2e91 commit 49f5e0f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/arduino_lorawan_begin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ bool Arduino_LoRaWAN::begin(
LMIC_reset();

// if we can get saved state, go on.
if (! this->RestoreSessionState())
auto const fHaveSavedState = this->RestoreSessionState();
if (! fHaveSavedState)
{
// Otherwise set data rate and transmit power, based on regional considerations.
this->NetBeginRegionInit();
Expand All @@ -69,7 +70,8 @@ bool Arduino_LoRaWAN::begin(
//
AbpProvisioningInfo abpInfo;

if (this->GetAbpProvisioningInfo(&abpInfo))
if ((fHaveSavedState || this->GetProvisioningStyle() == ProvisioningStyle::kABP) &&
this->GetAbpProvisioningInfo(&abpInfo))
{
LMIC_setSession(
abpInfo.NetID,
Expand Down

0 comments on commit 49f5e0f

Please sign in to comment.