Skip to content

Commit

Permalink
[LoRaWAN] Change session activation (#1093)
Browse files Browse the repository at this point in the history
* [LoRaWAN] Improve session restoration/activation behaviour

* [LoRaWAN] Custom return codes for session begin

* [LoRaWAN] Separate begin() and activate()

* [LoRaWAN] Fix activateABP()

* [LoRaWAN] Additional error-code

* [LoRaWAN] Fix rejoining during active session

* [LoRaWAN] Expose clearSession, drop `force`

* Update keywords...
  • Loading branch information
StevenCellist authored May 21, 2024
1 parent bfb27ec commit 298a612
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 271 deletions.
2 changes: 1 addition & 1 deletion examples/LoRaWAN/LoRaWAN_ABP/LoRaWAN_ABP.ino
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void setup() {

Serial.println(F("Initialise LoRaWAN Network credentials"));
state = node.beginABP(devAddr, fNwkSIntKey, sNwkSIntKey, nwkSEncKey, appSKey, true);
debug(state < RADIOLIB_ERR_NONE, F("Session setup failed"), state, true);
debug(state != RADIOLIB_LORAWAN_NEW_SESSION, F("Session setup failed"), state, true);

Serial.println(F("Ready!\n"));
}
Expand Down
6 changes: 3 additions & 3 deletions examples/LoRaWAN/LoRaWAN_Reference/LoRaWAN_Reference.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ void setup() {
debug(state != RADIOLIB_ERR_NONE, F("Initialise radio failed"), state, true);

// Override the default join rate
// uint8_t joinDR = 3;
uint8_t joinDR = 4;

Serial.println(F("Join ('login') to the LoRaWAN Network"));
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey, true);
debug(state < RADIOLIB_ERR_NONE, F("Join failed"), state, true);
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey, true, joinDR);
debug(state != RADIOLIB_LORAWAN_NEW_SESSION, F("Join failed"), state, true);

// Print the DevAddr
Serial.print("[LoRaWAN] DevAddr: ");
Expand Down
4 changes: 2 additions & 2 deletions examples/LoRaWAN/LoRaWAN_Starter/LoRaWAN_Starter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ void setup() {
debug(state != RADIOLIB_ERR_NONE, F("Initialise radio failed"), state, true);

Serial.println(F("Join ('login') to the LoRaWAN Network"));
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey, true);
debug(state < RADIOLIB_ERR_NONE, F("Join failed"), state, true);
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
debug(state != RADIOLIB_LORAWAN_NEW_SESSION, F("Join failed"), state, true);

Serial.println(F("Ready!\n"));
}
Expand Down
8 changes: 4 additions & 4 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,16 @@ checkDataRate KEYWORD2
setModem KEYWORD2

# LoRaWAN
wipe KEYWORD2
clearSession KEYWORD2
getBufferNonces KEYWORD2
setBufferNonces KEYWORD2
getBufferSession KEYWORD2
setBufferSession KEYWORD2
restore KEYWORD2
beginOTAA KEYWORD2
activateOTAA KEYWORD2
beginABP KEYWORD2
isJoined KEYWORD2
saveSession KEYWORD2
activateABP KEYWORD2
isActivated KEYWORD2
sendMacCommandReq KEYWORD2
uplink KEYWORD2
downlink KEYWORD2
Expand Down
20 changes: 20 additions & 0 deletions src/TypeDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,26 @@
*/
#define RADIOLIB_LORAWAN_NO_DOWNLINK (-1116)

/*!
\brief The LoRaWAN session was successfully re-activated.
*/
#define RADIOLIB_LORAWAN_SESSION_RESTORED (-1117)

/*!
\brief A new LoRaWAN session is started.
*/
#define RADIOLIB_LORAWAN_NEW_SESSION (-1118)

/*!
\brief The supplied Nonces buffer is discarded as its activation information is invalid.
*/
#define RADIOLIB_LORAWAN_NONCES_DISCARDED (-1119)

/*!
\brief The supplied Session buffer is discarded as it doesn't match the Nonces.
*/
#define RADIOLIB_LORAWAN_SESSION_DISCARDED (-1120)

// LR11x0-specific status codes

/*!
Expand Down
Loading

0 comments on commit 298a612

Please sign in to comment.