src/lmic/lmic_us_like.c
// map channels. return true if configuration looks valid.
map channels. return true if configuration looks valid.
map channels . return true if configuration looks valid .
bit_t LMICuslike_mapChannels(u1_t chpage, u2_t chmap) {
	if (chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_BANK) {
		for (u1_t subband = 0; subband < 8; ++subband, chmap >>= 1) {
			if (chmap & 1) {
				LMIC_enableSubBand(subband);
			} else {
				LMIC_disableSubBand(subband);
			}
		}
        } else {
                u1_t base, top;
                if (chpage < MCMD_LinkADRReq_ChMaskCntl_USLIKE_SPECIAL) {
                        base = chpage;
                        top = base + 16;
                        if (base == 64) {
                                top = 72;
                        }
                } else  {
                        u1_t const en125 = chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_125ON;
                        for (u1_t chnl = 0; chnl < 64; ++chnl) {
                                if (en125)
                                        LMIC_enableChannel(chnl);
                                else
                                        LMIC_disableChannel(chnl);
                        }
                        base = 64;
                        top = 72;
                }
                for (u1_t chnl = base; chnl < top; ++chnl, chmap >>= 1) {
                        if (chmap & 0x0001)
                                LMIC_enableChannel(chnl);
                        else
                                LMIC_disableChannel(chnl);
                }
        }
        LMICOS_logEventUint32("LMICuslike_mapChannels", ((u4_t)LMIC.activeChannels125khz << 16u)|(LMIC.activeChannels500khz << 0u));
	return (LMIC.activeChannels125khz > 0) || (LMIC.activeChannels500khz > 0);
}
bit_t LMICuslike_mapChannels ( u1_t chpage , u2_t chmap ) { if ( chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_BANK ) { for ( u1_t subband = 0 ; subband < 8 ; ++ subband , chmap >>= 1 ) { if ( chmap & 1 ) { LMIC_enableSubBand ( subband ) ; } else { LMIC_disableSubBand ( subband ) ; } } } else { u1_t base , top ; if ( chpage < MCMD_LinkADRReq_ChMaskCntl_USLIKE_SPECIAL ) { base = chpage ; top = base + 16 ; if ( base == 64 ) { top = 72 ; } } else { u1_t const en125 = chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_125ON ; for ( u1_t chnl = 0 ; chnl < 64 ; ++ chnl ) { if ( en125 ) LMIC_enableChannel ( chnl ) ; else LMIC_disableChannel ( chnl ) ; } base = 64 ; top = 72 ; } for ( u1_t chnl = base ; chnl < top ; ++ chnl , chmap >>= 1 ) { if ( chmap & 0x0001 ) LMIC_enableChannel ( chnl ) ; else LMIC_disableChannel ( chnl ) ; } } LMICOS_logEventUint32 ( " " , ( ( u4_t ) LMIC . activeChannels125khz << 16u ) | ( LMIC . activeChannels500khz << 0u ) ) ; return ( LMIC . activeChannels125khz > 0 ) || ( LMIC . activeChannels500khz > 0 ) ; }
map channels.
map channels .
/*
	|| MCMD_LinkADRReq_ChMaskCntl_USLIKE_125ON and MCMD_LinkADRReq_ChMaskCntl_USLIKE_125OFF are special. The
	|| channel map appllies to 500kHz (ch 64..71) and in addition
	|| all channels 0..63 are turned off or on.  MCMC_LADR_CHP_BANK
	|| is also special, in that it enables subbands.
	*/ // each bit enables a bank of channels // operate on channels 0..15, 16..31, 32..47, 48..63 // note that the chpage hasn't been shifted right, so // it's really the base. /* if (chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_125ON ||
                        chpage == MCMD_LinkADRReq_ChMaskCntl_USLIKE_125OFF) */ // enable or disable all 125kHz channels // then apply mask to top 8 channels. // apply chmap to channels in [base..top-1]. // Use enable/disable channel to keep activeChannel counts in sync.