General considerations
Waspmote Libraries
Waspmote XBee Files
Waspmote API files:
WaspXBeeCore.h WaspXBeeCore.cpp WaspXBee868LP.h WaspXBee868LP.cpp
It is mandatory to include the XBee 868LP library when using this module. The following line must be introduced at the beginning of the code:
#include <WaspXBee868LP.h>
Constructor
To start using the Waspmote XBee 868LP library, an object from class WaspXBee868LP
must be created. This object, called xbee868LP
, is created inside the Waspmote XBee 868LP library and it is public to all libraries. It is used through the guide to show how the Waspmote XBee 868LP library works.
When creating this constructor, no 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
Related Variables
sourceMacHigh[0-3]
→ stores the 32 upper bits of MAC address
sourceMacLow [0-3]
→ stores the 32 lower bits of MAC address
When returning from xbee868.getOwnMacLow()
the variable xbee868.sourceMacLow()
will be filled with the appropriate values. Before calling the function, the related variable is created but it is empty.
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 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 the parameter changes after power cycles, it is needed to execute the writeValues function.
Example of use
API extension
All the relevant and useful functions have been included in the Waspmote API, although any XBee AT commands can be sent directly to the transceiver calling the sendCommandAT()
function.
Example of use
Related Variables
commandAT[0-99]
→ 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 should not be bigger than 1500.
• MAX_PARSE
: (default value is 300) it defines the maximum data that is parsed in each call to parse_message()
. 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.
Last updated