ChannelMask
ChannelMask

Represents the channel mask (active and inactive channels) for a WirelessNode.

Constants
MAX_CHANNELS = 16

The maximum number of channels currently available on any node

Variables
m_channels[MAX_CHANNELS]
bool m_channels[MAX_CHANNELS]

An array of bools representing whether a channel is active or not

Functions
ChannelMask
explicit ChannelMask(
uint16 channelMask
)

Creates an ChannelMask object given a channel mask that was stored on a WirelessNode

Parameters
channelMask
uint16

A channel mask value from a WirelessNode representing the active and inactive channels

ChannelMask
ChannelMask()

The default constructor for creating an ChannelMask object, which sets all the channels to inactive

Operators
==

Equal operator for comparing ChannelMasks.

!=

Not Equal operator for comparing ChannelMasks.

<

Less Than operator for comparing ChannelMasks.

>

Greater Than operator for comparing ChannelMasks.

Functions
fromMask
void fromMask(
uint16 channelMask
)

Initializes the ChannelMask object from a channel mask

Parameters
channelMask
uint16

A channel mask value from a WirelessNode representing the active and inactive channels

toMask
uint16 toMask() const

Gets the channel mask value of the current ChannelMask object

Returns

The ChannelMask object represented as a channel mask

count
uint8 count() const

Gets the total number of active channels in the current ChannelMask object

Returns

The total number of active channels

enabled
bool enabled(
uint8 channel
) const

Checks whether a certain channel is enabled or disabled

Parameters
channel
uint8

The channel to check if enabled or disabled, based on index 1 (channel1 = 1, channel8 = 8)

Returns

true if the channel is enabled, false if the channel is disabled

enable
void enable(
uint8 channel,
bool enable true
)

Enables or disables a specified channel

Parameters
channel
uint8

The channel to enable or disable, based on index 1 (channel1 = 1, channel8 = 8)

enable
bool

Set to true to enable the channel, false to disable the channel

lastChEnabled
uint8 lastChEnabled() const

Finds the last channel (highest channel number) that is enabled in the mask.  This is useful when looping over the ChannelMask object and performing an action on all enabled channels.

Returns

The channel number (ch1 = 1, ch16 = 16) of the last channel enabled. 0 if no channels are enabled.