From b1d79b5883e606dfaaaa99a1f007d8dfa67f7e42 Mon Sep 17 00:00:00 2001 From: Terry Moore Date: Tue, 10 Sep 2019 19:16:53 -0400 Subject: [PATCH] Fix #446: AS923 don't report join failure till all ch scanned --- src/lmic/lmic.c | 10 +--------- src/lmic/lmic_eu_like.c | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/lmic/lmic.c b/src/lmic/lmic.c index e181c4e2..ec94ae04 100644 --- a/src/lmic/lmic.c +++ b/src/lmic/lmic.c @@ -1597,7 +1597,7 @@ static bit_t processJoinAccept (void) { ASSERT((LMIC.opmode & (OP_JOINING|OP_REJOIN))!=0); // // XXX(tmm@mcci.com) OP_REJOIN confuses me, and I'm not sure why we're - // adjusting DRs here. We've just recevied a join accept, and the + // adjusting DRs here. We've just received a join accept, and the // datarate therefore shouldn't be in play. In effect, we set the // initial data rate based on the number of times we tried to rejoin. // @@ -1672,18 +1672,10 @@ static bit_t processJoinAccept_nojoinframe(void) { // claimed to return a delay but really returns 0 or 1. // Once we update as923 to return failed after dr2, we // can take out this #if. -#if CFG_region != LMIC_REGION_as923 os_setTimedCallback(&LMIC.osjob, os_getTime()+failed, failed ? FUNC_ADDR(onJoinFailed) // one JOIN iteration done and failed : FUNC_ADDR(runEngineUpdate)); // next step to be delayed -#else - // in the join of AS923 v1.1 older, only DR2 is used. Therefore, - // not much improvement when it handles two different behavior; - // onJoinFailed or runEngineUpdate. - os_setTimedCallback(&LMIC.osjob, os_getTime()+failed, - FUNC_ADDR(onJoinFailed)); -#endif // stop this join process. return 1; } diff --git a/src/lmic/lmic_eu_like.c b/src/lmic/lmic_eu_like.c index fbaae360..982ae496 100644 --- a/src/lmic/lmic_eu_like.c +++ b/src/lmic/lmic_eu_like.c @@ -174,24 +174,25 @@ ostime_t LMICeulike_nextJoinState(uint8_t nDefaultChannels) { if ((++LMIC.txCnt % nDefaultChannels) == 0) { // Lower DR every nth try (having all default channels with same DR) // - // TODO(tmm@mcci.com) add new DR_REGIN_JOIN_MIN instead of LORAWAN_DR0; + // TODO(tmm@mcci.com) add new DR_REGION_JOIN_MIN instead of LORAWAN_DR0; // then we can eliminate the LMIC_REGION_as923 below because we'll set // the failed flag here. This will cause the outer caller to take the // appropriate join path. Or add new LMICeulike_GetLowestJoinDR() // + +// TODO(tmm@mcci.com) - see above; please remove regional dependency from this file. +#if CFG_region == LMIC_REGION_as923 + // in the join of AS923 v1.1 or older, only DR2 is used. + // no need to change the DR. + LMIC.datarate = AS923_DR_SF10; + failed = 1; +#else if (LMIC.datarate == LORAWAN_DR0) failed = 1; // we have tried all DR - signal EV_JOIN_FAILED - else - { -// TODO(tmm@mcci.com) - see above; please remove regional dependency from this file. -#if CFG_region != LMIC_REGION_as923 + else { LMICcore_setDrJoin(DRCHG_NOJACC, decDR((dr_t)LMIC.datarate)); -#else - // in the join of AS923 v1.1 or older, only DR2 is used. - // no need to change the DR. - LMIC.datarate = AS923_DR_SF10; -#endif } +#endif } // Clear NEXTCHNL because join state engine controls channel hopping LMIC.opmode &= ~OP_NEXTCHNL;