Skip to content

Commit 69c8b5f

Browse files
authored
Merge pull request #821 from mcci-catena/issue819
Fix corner cases for LinkADRReq; internal doc tweaks
2 parents 26326e4 + cad5146 commit 69c8b5f

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ The examples in this library (apart from the compliance sketch) are somewhat pri
120120

121121
Although the wrappers in this library are designed to make the LMIC useful in the Arduino environment, the maintainers have tried to be careful to keep the core LMIC code generally useful. For example, I use this library without modification (but with wrappers) on a RISC-V platform in a non-Arduino environment.
122122

123-
124123
## Installing
125124

126125
To install this library:
@@ -854,8 +853,7 @@ The library observes and processes rising edges on the pins as part of `os_runlo
854853
This can be configured in one of two ways (see
855854
[Controlling use of interrupts](#controlling-use-of-interrupts)). See [Interrupts and Arduino system timing](#interrupts-and-arduino-system-timing) for implementation details.
856855
857-
By default, the library
858-
polls the enabled pins to determine whether an event has occurred. This approach
856+
By default, the library polls the enabled pins to determine whether an event has occurred. This approach
859857
allows use of any CPU pin to sense the DIOs, and makes no assumptions about
860858
interrupts. However, it means that the end-of-transmit event is not observed
861859
(and time-stamped) until `os_runloop_once()` is called.

src/lmic/lmic.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,9 @@ applyAdrRequests(
764764
p4 = opts[oidx+4]; // ChMaskCtl, NbTrans
765765
u1_t chpage = p4 & MCMD_LinkADRReq_Redundancy_ChMaskCntl_MASK; // channel page
766766

767+
// notice that we ignore map_ok except on the last setting.
768+
// so LMICbandplan_mapChannels should report failure status, but do
769+
// the work; if it fails, we'll back it out.
767770
map_ok = LMICbandplan_mapChannels(chpage, chmap);
768771
LMICOS_logEventUint32("applyAdrRequests: mapChannels", ((u4_t)chpage << 16)|(chmap << 0));
769772
}

src/lmic/lmic_us_like.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ bit_t LMICuslike_canMapChannels(u1_t chpage, u2_t chmap) {
9999
|| channel map appllies to 500kHz (ch 64..71) and in addition
100100
|| all channels 0..63 are turned off or on. MCMC_LADR_CHP_BANK
101101
|| is also special, in that it enables subbands.
102+
||
103+
|| TODO([email protected]) revise the 0xFF00 mask for regions with other than
104+
|| eight 500 kHz channels.
102105
*/
103106
if (chpage < MCMD_LinkADRReq_ChMaskCntl_USLIKE_SPECIAL) {
104107
// operate on channels 0..15, 16..31, 32..47, 48..63, 64..71
@@ -111,17 +114,22 @@ bit_t LMICuslike_canMapChannels(u1_t chpage, u2_t chmap) {
111114
return 1;
112115
}
113116
} else if (chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_BANK) {
114-
if (chmap == 0 || (chmap & 0xFF00) != 0) {
115-
// no bits set, or reserved bitsset , fail.
117+
if ((chmap & 0xFF00) != 0) {
118+
// Reserved bits set, fail.
116119
return 0;
117120
}
118121
} else if (chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_125ON ||
119122
chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_125OFF) {
120-
u1_t const en125 = chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_125ON;
121-
122-
// if disabling all 125kHz chans, must have at least one 500kHz chan
123-
// don't allow reserved bits to be set in chmap.
124-
if ((! en125 && chmap == 0) || (chmap & 0xFF00) != 0)
123+
//
124+
// if disabling all 125kHz chans, you might think we must have
125+
// at least one 500kHz chan; but that's a local conclusion.
126+
// Some network servers will disable all (including 500kHz)
127+
// then turn things back on in the next LinkADRReq. So
128+
// we can't fail that here.
129+
//
130+
// But don't allow reserved bits to be set in chmap.
131+
//
132+
if ((chmap & 0xFF00) != 0)
125133
return 0;
126134
} else {
127135
return 0;

0 commit comments

Comments
 (0)