General considerations
Waspmote libraries
Waspmote XBee files
Waspmote API files: WaspXBeeCore.h WaspXBeeCore.cpp WaspXBee900HP.h WaspXBee900HP.cpp
It is mandatory to include the XBee 900HP library when using this module. The following line must be introduced at the beginning of the code:
#include <WaspXBee900HP.h>
Constructor
To start using the Waspmote XBee 900HP library, an object from class WaspXBee900HP
must be created. This object, called xbee900HP
, is created inside the Waspmote XBee 900HP library and it is public to all libraries. It is used through the guide to show how the Waspmote XBee 900HP 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:
xbee900HP.sourceMacHigh[0-3]
→ stores the 32 upper bits of MAC address
xbee900HP.sourceMacLow [0-3]
→ stores the 32 lower bits of MAC address
When returning from xbee900HP.getOwnMacLow()
, the exposed variable xbee900HP.sourceMacLow
will be filled with the appropriate values. Before calling the function, the exposed 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 functionerror_RX
: it stores if some error occurred during the reception of a packeterror_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:
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:
xbee900HP.commandAT[0-99]
→ stores the response given by the module up to 100 bytes
Sending AT commands example:
https://development.libelium.com/waspmote/900hp-11-send-atcommand
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 1500MAX_PARSE
: (default value is 300) it defines the maximum data that is parsed in each call toparse_message()
. If more data are received, they will be stored in the UART buffer until the next call totreatData()
. However, if the UART buffer is full, the following data will be written on the buffer, so be careful with this matterMAX_BROTHERS
: (default value is 5) it defines the maximum number of brothers that can be stored
Last updated