Skip to content

Commit

Permalink
Complete as923 bandplan: resolve issue [#31](#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrillmoore committed Sep 18, 2017
1 parent 7386286 commit b87bab1
Show file tree
Hide file tree
Showing 6 changed files with 509 additions and 5 deletions.
30 changes: 30 additions & 0 deletions src/lmic/lmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ scan_mac_cmds(
u1_t uprpt = opts[oidx+4] & MCMD_LADR_REPEAT_MASK; // up repeat count
oidx += 5;

// TODO([email protected]): LoRaWAN 1.1 requires us to process multiple
// LADR requests, and only update if all pass. So this should check
// ladrAns == 0, and only initialize if so. Need to repeat ACKs, so
// we need to count the number we see.
LMIC.ladrAns = 0x80 | // Include an answer into next frame up
MCMD_LADR_ANS_POWACK | MCMD_LADR_ANS_CHACK | MCMD_LADR_ANS_DRACK;
if( !LMICbandplan_mapChannels(chpage, chmap) )
Expand All @@ -569,6 +573,10 @@ scan_mac_cmds(
e_.info = Base::lsbf4(&d[pend]),
e_.info2 = Base::msbf4(&opts[oidx-4])));
}
// TODO([email protected]): see above; this needs to move outside the
// txloop. And we need to have "consistent" ansswers for the block
// of contiguous commands (whatever that means), and ignore the
// data rate, NbTrans (uprpt) and txPow until the last one.
if( (LMIC.ladrAns & 0x7F) == (MCMD_LADR_ANS_POWACK | MCMD_LADR_ANS_CHACK | MCMD_LADR_ANS_DRACK) ) {
// Nothing went wrong - use settings
LMIC.upRepeat = uprpt;
Expand Down Expand Up @@ -672,6 +680,21 @@ scan_mac_cmds(
oidx += 4;
continue;
} /* end case */
case MCMD_TxParamSetupReq: {
#if LMIC_ENABLE_TxParamSetupReq
uint8_t txParam;
txParam = opts[oidx+1];

// we don't allow unrecognized bits to come through
txParam &= (MCMD_TxParam_RxDWELL_MASK|
MCMD_TxParam_TxDWELL_MASK|
MCMD_TxParam_MaxEIRP_MASK);
LMIC.txParam = txParam;
LMIC.txParamSetupAns = 1;
#endif // LMIC_ENABLE_TxParamSetupReq
oidx += 2;
continue;
} /* end case */
} /* end switch */
/* unrecognized mac commands fall out of switch to here */
EV(specCond, ERR, (e_.reason = EV::specCond_t::BAD_MAC_CMD,
Expand Down Expand Up @@ -1222,6 +1245,13 @@ static void buildDataFrame (void) {
LMIC.snchAns = 0;
}
#endif // !DISABLE_MCMD_SNCH_REQ
#if LMIC_ENABLE_TxParamSetupReq
if ( LMIC.txParamSetupAns ) {
LMIC.frame[end+0] = MCMD_TxParamSetupAns;
end += 1;
LMIC.txParamSetupAns = 0;
}
#endif
ASSERT(end <= OFF_DAT_OPTS+16);

u1_t flen = end + (txdata ? 5+dlen : 4);
Expand Down
13 changes: 9 additions & 4 deletions src/lmic/lmic.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
# endif // ndef LMIC_DEBUG_FLUSH
#else // LMIC_DEBUG_LEVEL == 0
// If debug level is zero, printf and flush expand to nothing.
# define LMIC_DEBUG_PRINTF(f, ...) do { ; } while (0)
# define LMIC_DEBUG_FLUSH() do { ; } while (0)
# define LMIC_DEBUG_PRINTF(f, ...) do { ; } while (0)
# define LMIC_DEBUG_FLUSH() do { ; } while (0)
#endif // LMIC_DEBUG_LEVEL == 0

#ifdef __cplusplus
Expand Down Expand Up @@ -276,6 +276,11 @@ struct lmic_t {
#if !defined(DISABLE_MCMD_SNCH_REQ)
u1_t snchAns; // answer set new channel
#endif
#if LMIC_ENABLE_TxParamSetupReq
bit_t txParamSetupAns; // transmit setup answer pending.
u1_t txParam; // the saved TX param byte.
#endif

// rx1DrOffset is the offset from uplink to downlink datarate
u1_t rx1DrOffset; // captured from join. zero by default.

Expand Down Expand Up @@ -359,8 +364,8 @@ void LMIC_setSession (u4_t netid, devaddr_t devaddr, xref2u1_t nwkKey, xref2u1_t
void LMIC_setLinkCheckMode (bit_t enabled);
void LMIC_setClockError(u2_t error);

u4_t LMIC_getSeqnoUp (void);
u4_t LMIC_setSeqnoUp (u4_t);
u4_t LMIC_getSeqnoUp (void);
u4_t LMIC_setSeqnoUp (u4_t);
void LMIC_getSessionKeys (u4_t *netid, devaddr_t *devaddr, xref2u1_t nwkKey, xref2u1_t artKey);

// Declare onEvent() function, to make sure any definition will have the
Expand Down
Loading

0 comments on commit b87bab1

Please sign in to comment.