mcci-catena/arduino-lmic

`LMICuslike_canMapChannels` should not reject zero mask when setting bank-by-bank

terrillmoore opened this issue · 0 comments

In preparing the fix for #819, discovered a similar (but unreported) problem with the setting of channel masks directly here:

} else if (chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_BANK) {
if (chmap == 0 || (chmap & 0xFF00) != 0) {
// no bits set, or reserved bitsset , fail.
return 0;
}

Originally posted by @terrillmoore in #819 (comment)

Filed as a separate bug because it's independent of #819, but want to use same PR.

As with #819, the problem is that we can't reject "all channels off" while processing a MAC command; another in the same message might turn some on. We can only check minimum number of channels after all MAC commands have been parsed. It's fine to have the second part of the if, because out-of-range channels are illegal; but not ok to have the first (because we don't know that all channels off is illegal yet).