General Considerations

Waspmote Libraries

Waspmote XBee Files

The Waspmote XBee library is compatible with both XBee ZigBee 3 and XBee ZigBee S2D modules.
WaspXBeeCore.h, WaspXBeeCore.cpp, WaspXBeeZB.h, WaspXBeeZB.cpp
It is mandatory to include the XBee ZigBee library when using this module. The following line must be introduced at the beginning of the code:
#include \


To start using Waspmote XBee library, an object from class WaspXBeeZB must be created. This object, called xbeeZB, is created inside 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
xbeeZB.getOwnMacLow(); // Get 32 lower bits of MAC Address
xbeeZB.getOwnMacHigh(); // Get 32 upper bits of MAC Address
Related variables:
xbeeZB.sourceMacHigh[0-3] → stores the 32 upper bits of MAC address
xbeeZB.sourceMacLow [0-3] → stores the 32 lower bits of MAC address
When returning from xbeeZB.getOwnMacLow the related variable xbeeZB.sourceMacLow will be filled with the appropriate values. Before calling the function, the related variable is created but it is empty. Almost every function has a related variable, and it will be indicated when the function was explained.
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 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 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
xbeeZB.writeValues(); // Keep values after rebooting

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
xbeeZB.sendCommandAT("CH#"); // Executes command ATCH
Related variables:
xbeeZB.commandAT[0-99] → stores the response given by the module up to 100 Bytes
• Send command AT 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.