src/lmic/lmic_in866.c
///
/// \brief LMIC_setupChannel for IN region
///
/// \note according to LoRaWAN 1.3 section 5.6, "the acceptable range
///     for **ChIndex** is N to 16", where N is our \c NUM_DEFAULT_CHANNELS.
///     This routine is used internally for MAC commands, so we enforce
///     this for the extenal API as well.
///
\brief LMIC_setupChannel for IN region
\note according to LoRaWAN 1.3 section 5.6, "the acceptable range
for **ChIndex** is N to 16", where N is our \c NUM_DEFAULT_CHANNELS.
This routine is used internally for MAC commands, so we enforce
this for the extenal API as well.
\ brief LMIC_setupChannel for IN region \ note according to LoRaWAN 1 . 3 section 5 . 6 " the acceptable range for ** ChIndex ** is N to 16 " where N is our \ c NUM_DEFAULT_CHANNELS . This routine is used internally for MAC commands so we enforce this for the extenal API as well .
bit_t LMIC_setupChannel(u1_t chidx, u4_t freq, u2_t drmap, s1_t band) {
        freq &= ~3;
        if (chidx < NUM_DEFAULT_CHANNELS) {
                return 0;
        }
        bit_t fEnable = (freq != 0);
        if (chidx >= MAX_CHANNELS)
                return 0;
        if (band == -1) {
                freq = (freq&~3) | BAND_MILLI;
        } else {
                if (band > BAND_MILLI) return 0;
                freq = (freq&~3) | band;
        }
        LMIC.channelFreq[chidx] = freq;
        LMIC.channelDrMap[chidx] = drmap == 0 ? DR_RANGE_MAP(IN866_DR_SF12, IN866_DR_SF7) : drmap;
        if (fEnable)
                LMIC.channelMap |= 1 << chidx;  
        else
                LMIC.channelMap &= ~(1 << chidx);
        return 1;
}
bit_t LMIC_setupChannel ( u1_t chidx , u4_t freq , u2_t drmap , s1_t band ) { freq &= ~ 3 ; if ( chidx < NUM_DEFAULT_CHANNELS ) { return 0 ; } bit_t fEnable = ( freq != 0 ) ; if ( chidx >= MAX_CHANNELS ) return 0 ; if ( band == -1 ) { freq = ( freq & ~ 3 ) | BAND_MILLI ; } else { if ( band > BAND_MILLI ) return 0 ; freq = ( freq & ~ 3 ) | band ; } LMIC . channelFreq [ chidx ] = freq ; LMIC . channelDrMap [ chidx ] = drmap == 0 ? DR_RANGE_MAP ( IN866_DR_SF12 , IN866_DR_SF7 ) : drmap ; if ( fEnable ) LMIC . channelMap |= 1 << chidx ; else LMIC . channelMap &= ~ ( 1 << chidx ) ; return 1 ; }
\brief LMIC_setupChannel for IN region
\note according to LoRaWAN 1.3 section 5.6, "the acceptable range
for **ChIndex** is N to 16", where N is our \c NUM_DEFAULT_CHANNELS.
\ brief LMIC_setupChannel for IN region \ note according to LoRaWAN 1 . 3 section 5 . 6 " the acceptable range for ** ChIndex ** is N to 16 " where N is our \ c NUM_DEFAULT_CHANNELS .
// zero the band bits in freq, just in case. // enabled right away