From b0e4616e7ab087a94ab470094d25852d2609e6b2 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 7 Jun 2017 09:58:16 +0000 Subject: [PATCH 1/3] Fix infinite join retry --- src/TheThingsNetwork.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 6fc51c47..1508400e 100755 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -501,7 +501,7 @@ bool TheThingsNetwork::join(int8_t retries, uint32_t retryDelay) { configureChannels(fsb); setSF(sf); - while (retries == -1 || retries-- >= 0) + while (retries == -1 || retries-- > 0) { if (!sendJoinSet(MAC_JOIN_MODE_OTAA)) { From e5365c42c49a3bbfceb2731f73f5b105ff71e32a Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 7 Jun 2017 11:26:07 +0000 Subject: [PATCH 2/3] Introduce attempts variable Attempts is incremented every time before a join. Behaviour is now: `ttn.join(appEui, appKey, 2);` - Tries 3 times to join. `ttn.join(appEui, appKey, 0);` - Tries 1 time to join. `ttn.join(appEui, appKey, -1);` - Tries infinitely to join. `ttn.join(appEui, appKey, -2);` - Tries 0 times to join. --- src/TheThingsNetwork.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 1508400e..cee9e67e 100755 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -499,10 +499,12 @@ bool TheThingsNetwork::provision(const char *appEui, const char *appKey) bool TheThingsNetwork::join(int8_t retries, uint32_t retryDelay) { + int8_t attempts = 0; configureChannels(fsb); setSF(sf); - while (retries == -1 || retries-- > 0) + while (retries == -1 || attempts <= retries) { + attempts++; if (!sendJoinSet(MAC_JOIN_MODE_OTAA)) { debugPrintMessage(ERR_MESSAGE, ERR_JOIN_FAILED); From fa757aca6bb853d26852e5380cbbe90e37d4c633 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 7 Jun 2017 11:30:32 +0000 Subject: [PATCH 3/3] Version bump We will need this fix for the KISS LoRa gadget update. --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 09525b64..0ac00bfa 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TheThingsNetwork -version=2.5.2 +version=2.5.3 author=The Things Network maintainer=Johan Stokking sentence=The Things Network Arduino Library.