General Considerations

Waspmote Libraries

Waspmote XBee files

The Waspmote XBee library is compatible with both XBee 3 802.15.4 EU and XBee 3 802.15.4 modules.

WaspXBeeCore.h, WaspXBeeCore.cpp, WaspXBee802.h, WaspXBee802.cpp

It is mandatory to include the XBee802 library when using this module. The following line must be introduced at the beginning of the code:

#include <WaspXBee802.h>


To start using the Waspmote XBee library, an object from class 'WaspXBee802' must be created. This object, called xbee802, is created inside the Waspmote XBee library and it is public to all libraries. It is used through the guide to show how the Waspmote XBee library works.

When creating this constructor, some variables are defined with a value by default.

API functions

Through the guide there are many examples of using parameters. In these examples, API functions are called to execute the commands, storing in their related variables the parameter value in each case.

Example of use:

xbee802.getOwnMacLow(); // Get 32 lower bits of MAC Address
xbee802.getOwnMacHigh(); // Get 32 upper bits of MAC Address

Related variables:

xbee802.sourceMacHigh[0-3] // stores the 32 upper bits of MAC address
xbee802.sourceMacLow [0-3] // stores the 32 lower bits of MAC address

When returning from xbee802.getOwnMacLow() the related variable xbee802.sourceMacLow will be filled with the appropriate values. Before calling the function, the related variable is created but it is empty or with a default value.

There are three error flags that are filled when the function is executed:

  • error_AT: it stores if some error occurred during the execution of

    an AT command function

  • error_RX: it stores if some error occurred during the reception of a packet

  • error_TX: it stores if some error occurred during the transmission of a packet

All the functions also return a flag to know if the function called was successful or not. Available values for this flag:

  • 0 : Success. The function was executed without errors and the exposed variable was filled.

  • 1 : Error. The function was executed but an error occurred while executing.

  • 2 : Not executed. An error occurred before executing the function.

  • -1 : Function not allowed in this module.

To store parameter changes after power cycles, it is needed to execute the writeValues() function.

Example of use:

xbee802.writeValues(); // Keep values after power down

API extension

All the relevant and useful functions have been included in the Waspmote API, although any XBee command can be sent directly to the transceiver.

Example of use:

xbee802.sendCommandAT("CH#"); // Executes command ATCH

Related variables:

xbee802.commandAT[0-100] // stores the response given by the module up to 100 bytes

Sending AT commands example:‚Äč

Waspmote reboot

When Waspmote is rebooted the application code will start again, creating all the variables and objects from the beginning.

Constants pre-defined

There are some constants pre-defined in a file called 'WaspXBeeCore.h'. These constants define some parameters like the maximum data size. The most important constants are explained next:

  • MAX_DATA: (default value is 300) it defines the maximum available data size for a packet. This constant must be equal or bigger than the data is sent on each packet. This size shouldn't be bigger than 1500.

  • MAX_PARSE: (default value is 300) it defines the maximum data that is parsed in each call to treatData(). If more data are received, they will be stored in the UART buffer until the next call to treatData(). However, if the UART buffer is full, the following data will be written on the buffer, so be careful with this matter.

  • MAX_BROTHERS: (default value is 5) it defines the maximum number of brothers that can be stored.