Initialization

Before starting to use a module, it needs to be initialized. During this process, the UART to communicate with the module has to be opened and the XBee switch has to be set on.

Setting on

The ON() function initializes all the global variables, opens the correspondent UART and switches the XBee ON. The baud rate used to open the UART is defined on the library (115200 bps by default).

It returns nothing.

The initialized variables are:

  • protocol: specifies the protocol used (802.15.4 in this case).

  • pos: specifies the position to use in received packets.

  • discoveryOptions: specifies the options in Node Discovery.

  • awakeTime: specifies the time to be awake before go sleeping.

  • sleepTime: specifies the time to be sleeping.

  • scanChannels: specifies the channels to scan.

  • scanTime: specifies the time to scan each channel.

  • encryptMode: specifies if encryption mode is enabled.

  • powerLevel: specifies the power transmission level.

  • timeRSSI: specifies the time RSSI LEDs are on.

  • sleepOptions: specifies the options for sleeping.

  • retries: specifies the number of retries to execute in addition to the three retries defined in the 802.15.4 protocol.

  • delaySlots: specifies the minimum value of the back-off exponent in CSMA/CA.

  • macMode: specifies the Mac Mode used.

  • energyThreshold: specifies the energy threshold used to determine if the channel is free.

  • counterCCA: specifies the number of times too much energy was found in the channel.

  • counterACK: specifies the number of times an ACK was lost.

Example of use:

{
xbee802.ON();
}

Setting off

The OFF() function closes the UART and switches the XBee OFF.

Example of use:

{
xbee802.OFF();
}