Skip to content

Commit

Permalink
Fix #404: remove XCHANNEL support from US region
Browse files Browse the repository at this point in the history
  • Loading branch information
terrillmoore committed Apr 19, 2021
1 parent d248d76 commit d86e4c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ If the library is configured for US915 operation, we make the following changes:

- Add the APIs `LMIC_enableChannel()`,
`LMIC_enableSubBand()`, `LMIC_disableSubBand()`, and `LMIC_selectSubBand()`.
- Add the constants `MAX_XCHANNELS`.
- Add a number of additional `DR_...` symbols.

### Selecting the target radio transceiver
Expand Down
8 changes: 2 additions & 6 deletions src/lmic/lmic.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,8 @@ struct lmic_saved_adr_state_s {

#elif CFG_LMIC_US_like // US915 spectrum =================================================

enum { MAX_XCHANNELS = 2 }; // extra channels in RAM, channels 0-71 are immutable

struct lmic_saved_adr_state_s {
u2_t channelMap[(72+MAX_XCHANNELS+15)/16]; // enabled bits
u2_t channelMap[(72+15)/16]; // enabled bits
u2_t activeChannels125khz;
u2_t activeChannels500khz;
};
Expand Down Expand Up @@ -532,9 +530,7 @@ struct lmic_t {
u2_t channelDrMap[MAX_CHANNELS];
u2_t channelMap;
#elif CFG_LMIC_US_like
u4_t xchFreq[MAX_XCHANNELS]; // extra channel frequencies (if device is behind a repeater)
u2_t xchDrMap[MAX_XCHANNELS]; // extra channel datarate ranges ---XXX: ditto
u2_t channelMap[(72+MAX_XCHANNELS+15)/16]; // enabled bits
u2_t channelMap[(72+15)/16]; // enabled bits
u2_t activeChannels125khz;
u2_t activeChannels500khz;
#endif
Expand Down
23 changes: 7 additions & 16 deletions src/lmic/lmic_us915.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,17 @@ u4_t LMICus915_convFreq(xref2cu1_t ptr) {
}

bit_t LMIC_setupChannel(u1_t chidx, u4_t freq, u2_t drmap, s1_t band) {
LMIC_API_PARAMETER(chidx);
LMIC_API_PARAMETER(freq);
LMIC_API_PARAMETER(drmap);
LMIC_API_PARAMETER(band);

if (chidx < 72 || chidx >= 72 + MAX_XCHANNELS)
return 0; // channels 0..71 are hardwired
LMIC.xchFreq[chidx - 72] = freq;
// TODO(tmm@mcci.com): don't use US SF directly, use something from the LMIC context or a static const
LMIC.xchDrMap[chidx - 72] = drmap == 0 ? DR_RANGE_MAP(US915_DR_SF10, US915_DR_SF8C) : drmap;
LMIC.channelMap[chidx >> 4] |= (1 << (chidx & 0xF));
return 1;
return 0; // channels 0..71 are hardwired
}

bit_t LMIC_disableChannel(u1_t channel) {
bit_t result = 0;
if (channel < 72 + MAX_XCHANNELS) {
if (channel < 72) {
if (ENABLED_CHANNEL(channel)) {
result = 1;
if (IS_CHANNEL_125khz(channel))
Expand All @@ -128,7 +125,7 @@ bit_t LMIC_disableChannel(u1_t channel) {

bit_t LMIC_enableChannel(u1_t channel) {
bit_t result = 0;
if (channel < 72 + MAX_XCHANNELS) {
if (channel < 72) {
if (!ENABLED_CHANNEL(channel)) {
result = 1;
if (IS_CHANNEL_125khz(channel))
Expand Down Expand Up @@ -197,13 +194,7 @@ void LMICus915_updateTx(ostime_t txbeg) {
} else {
// at 500kHz bandwidth, we're allowed more power.
LMIC.txpow = 26;
if (chnl < 64 + 8) {
LMIC.freq = US915_500kHz_UPFBASE + (chnl - 64)*US915_500kHz_UPFSTEP;
}
else {
ASSERT(chnl < 64 + 8 + MAX_XCHANNELS);
LMIC.freq = LMIC.xchFreq[chnl - 72];
}
LMIC.freq = US915_500kHz_UPFBASE + (chnl - 64)*US915_500kHz_UPFSTEP;
}

// Update global duty cycle stats
Expand Down

0 comments on commit d86e4c5

Please sign in to comment.