Merge pull request #936 from StevenCellist/master
[LoRaWAN] Fix session restore throwing unnecessary error
This commit is contained in:
commit
86136d3b46
4 changed files with 9 additions and 9 deletions
|
@ -102,7 +102,7 @@ void setup() {
|
||||||
Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
|
Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
|
||||||
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
|
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
|
||||||
|
|
||||||
if(state == RADIOLIB_ERR_NONE) {
|
if(state >= RADIOLIB_ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
Serial.print(F("failed, code "));
|
Serial.print(F("failed, code "));
|
||||||
|
|
|
@ -110,7 +110,7 @@ void setup() {
|
||||||
// start the device by directly providing the encryption keys and device address
|
// start the device by directly providing the encryption keys and device address
|
||||||
Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
|
Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
|
||||||
state = node.beginABP(devAddr, nwkSKey, appSKey, fNwkSIntKey, sNwkSIntKey);
|
state = node.beginABP(devAddr, nwkSKey, appSKey, fNwkSIntKey, sNwkSIntKey);
|
||||||
if(state == RADIOLIB_ERR_NONE) {
|
if(state >= RADIOLIB_ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
Serial.print(F("failed, code "));
|
Serial.print(F("failed, code "));
|
||||||
|
|
|
@ -100,7 +100,7 @@ void setup() {
|
||||||
Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
|
Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
|
||||||
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
|
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
|
||||||
|
|
||||||
if(state == RADIOLIB_ERR_NONE) {
|
if(state >= RADIOLIB_ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
Serial.print(F("failed, code "));
|
Serial.print(F("failed, code "));
|
||||||
|
|
|
@ -65,17 +65,17 @@ int16_t LoRaWANNode::restore() {
|
||||||
// }
|
// }
|
||||||
(void)nvm_table_version;
|
(void)nvm_table_version;
|
||||||
|
|
||||||
// check the magic value
|
// check the mode value
|
||||||
uint8_t lwMode = mod->hal->getPersistentParameter<uint8_t>(RADIOLIB_EEPROM_LORAWAN_MODE_ID);
|
uint16_t lwMode = mod->hal->getPersistentParameter<uint16_t>(RADIOLIB_EEPROM_LORAWAN_MODE_ID);
|
||||||
if(lwMode == RADIOLIB_LORAWAN_MODE_NONE) {
|
if(lwMode == RADIOLIB_LORAWAN_MODE_NONE) {
|
||||||
#if RADIOLIB_DEBUG
|
#if RADIOLIB_DEBUG
|
||||||
RADIOLIB_DEBUG_PRINTLN("magic id not set (no saved session)");
|
RADIOLIB_DEBUG_PRINTLN("mode value not set (no saved session)");
|
||||||
RADIOLIB_DEBUG_PRINTLN("first 16 bytes of NVM:");
|
RADIOLIB_DEBUG_PRINTLN("first 16 bytes of NVM:");
|
||||||
uint8_t nvmBuff[16];
|
uint8_t nvmBuff[16];
|
||||||
mod->hal->readPersistentStorage(mod->hal->getPersistentAddr(0), nvmBuff, 16);
|
mod->hal->readPersistentStorage(mod->hal->getPersistentAddr(0), nvmBuff, 16);
|
||||||
RADIOLIB_DEBUG_HEXDUMP(nvmBuff, 16);
|
RADIOLIB_DEBUG_HEXDUMP(nvmBuff, 16);
|
||||||
#endif
|
#endif
|
||||||
// the magic value is not set, user will have to do perform the join procedure
|
// the mode value is not set, user will have to do perform the join procedure
|
||||||
return(RADIOLIB_ERR_NETWORK_NOT_JOINED);
|
return(RADIOLIB_ERR_NETWORK_NOT_JOINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ int16_t LoRaWANNode::beginOTAA(uint64_t joinEUI, uint64_t devEUI, uint8_t* nwkKe
|
||||||
return(this->restore());
|
return(this->restore());
|
||||||
} else {
|
} else {
|
||||||
#if RADIOLIB_DEBUG
|
#if RADIOLIB_DEBUG
|
||||||
RADIOLIB_DEBUG_PRINTLN("Failed to restore session (checksum: %d, mode: %d)", validCheckSum, validMode);
|
RADIOLIB_DEBUG_PRINTLN("Didn't restore session (checksum: %d, mode: %d)", validCheckSum, validMode);
|
||||||
RADIOLIB_DEBUG_PRINTLN("First 16 bytes of NVM:");
|
RADIOLIB_DEBUG_PRINTLN("First 16 bytes of NVM:");
|
||||||
uint8_t nvmBuff[16];
|
uint8_t nvmBuff[16];
|
||||||
mod->hal->readPersistentStorage(mod->hal->getPersistentAddr(0), nvmBuff, 16);
|
mod->hal->readPersistentStorage(mod->hal->getPersistentAddr(0), nvmBuff, 16);
|
||||||
|
@ -683,7 +683,7 @@ int16_t LoRaWANNode::beginABP(uint32_t addr, uint8_t* nwkSKey, uint8_t* appSKey,
|
||||||
return(this->restore());
|
return(this->restore());
|
||||||
} else {
|
} else {
|
||||||
#if RADIOLIB_DEBUG
|
#if RADIOLIB_DEBUG
|
||||||
RADIOLIB_DEBUG_PRINTLN("Failed to restore session (checksum: %d, mode: %d)", validCheckSum, validMode);
|
RADIOLIB_DEBUG_PRINTLN("Didn't restore session (checksum: %d, mode: %d)", validCheckSum, validMode);
|
||||||
RADIOLIB_DEBUG_PRINTLN("First 16 bytes of NVM:");
|
RADIOLIB_DEBUG_PRINTLN("First 16 bytes of NVM:");
|
||||||
uint8_t nvmBuff[16];
|
uint8_t nvmBuff[16];
|
||||||
mod->hal->readPersistentStorage(mod->hal->getPersistentAddr(0), nvmBuff, 16);
|
mod->hal->readPersistentStorage(mod->hal->getPersistentAddr(0), nvmBuff, 16);
|
||||||
|
|
Loading…
Add table
Reference in a new issue