Skip to content

Commit e5365c4

Browse files
authored
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.
1 parent b0e4616 commit e5365c4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/TheThingsNetwork.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,12 @@ bool TheThingsNetwork::provision(const char *appEui, const char *appKey)
499499

500500
bool TheThingsNetwork::join(int8_t retries, uint32_t retryDelay)
501501
{
502+
int8_t attempts = 0;
502503
configureChannels(fsb);
503504
setSF(sf);
504-
while (retries == -1 || retries-- > 0)
505+
while (retries == -1 || attempts <= retries)
505506
{
507+
attempts++;
506508
if (!sendJoinSet(MAC_JOIN_MODE_OTAA))
507509
{
508510
debugPrintMessage(ERR_MESSAGE, ERR_JOIN_FAILED);

0 commit comments

Comments
 (0)