General considerations
Waspmote libraries
Waspmote SX1272 files
WaspSX1272.h, WaspSX1272.cpp
It is mandatory to include the SX1272 library when using this module. The following line must be introduced at the beginning of the code:
Constructor
To start using the Waspmote SX1272 library, an object from class WaspSX1272
must be created. This object, called sx1272
, is created inside the Waspmote SX1272 library and it is public to all libraries. It is used through the guide to show how the Waspmote SX1272 library works.
When creating this object, 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:
Related variables:
sx1272._preamblelength
→ stores the preamble length
When returning from sx1272.getPreambleLength()
the variable sx1272._preamblelength
will be filled with the appropriate values.
Before calling the function, the related variable is created but it is empty.
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 mode.
The main functions are listed here:
Basic functions
Function | Definition |
WaspSX1272(); | Class constructor. |
ON(); | Opens the SPI and switches the SX1272 module on. |
OFF(); | Closes the SPI and switches the SX1272 module off. |
readRegister(); | Reads the indicated internal register. |
writeRegister(); | Writes the indicated internal register. |
clearFlags(); | Clears the interruption flags. |
Configuration functions
Function | Definition |
setLORA(); | Sets the module in LoRa transmission mode. |
getMode(); | Gets the BW, CR and SF of the LoRa modulation. |
setMode(); | Sets the BW, CR and SF of the LoRa modulation. |
getHeader(); | Indicates if module is configured in implicit or explicit header mode. |
setHeaderON(); | Sets the module in explicit header mode (header is sent). |
setHeaderOFF(); | Sets the module in implicit header mode (header is not sent). |
getCRC(); | Indicates if module is configured with or without checking CRC. |
setCRC_ON(); | Sets the module with CRC on. |
setCRC_OFF(); | Sets the module with CRC off. |
getChannel(); | Indicates the frequency channel within the module is configured. |
setChannel(); | Sets the indicated frequency channel in the module. |
getPower(); | Gets the signal power within the module is configured. |
setPower(); | Sets the signal power indicated in the module. |
setPowerNum(); | Sets the signal power indicated in the module. |
getPreambleLength(); | Gets the preamble length from the module. |
setPreambleLength(); | Sets the preamble length in the module. |
getPayloadLength(); | Gets the payload length from the module. |
setPacketLength(); | Sets the packet length in the module. |
getNodeAddress(); | Gets the node address in the module. |
setNodeAddress(); | Sets the node address in the module. |
setRetries(); | Sets the maximum number of retries. |
getMaxCurrent(); | Gets the current supply limit of the internal power amplifier. |
setMaxCurrent(); | Limits the current supply of the internal power amplifier. |
getTemp(); | Gets the temperature from the measurement block module. |
getRegs(); | Gets the content of different registers. |
Link information functions
Function | Definition |
getSNR(); | Gets the SNR value in LoRa mode. |
getRSSI(); | Gets the current value of RSSI from the channel. |
getRSSIpacket(); | Gets the RSSI of the last packet received in LoRa mode. |
Sending functions
Function | Definition |
sendPacketTimeout(); | Sends a packet to the specified destination before a timeout expires. |
sendPacketMaxTimeout(); | Same as previous function with maximum timeout. |
sendPacketTimeoutACK(); | Sends a packet to a destination before a timeout and wait for an ACK response. |
sendPacketMaxTimeoutACK(); | Same as previous function with maximum timeout. |
sendPacketTimeoutACKRetries(); | Sends a packet to a destination before a timeout, wait for an ACK response and retry to send the packet if ACK is lost. |
sendPacketMaxTimeoutACKRetries(); | Same as previous function with maximum timeout. |
Receiving functions
Function | Definition |
receivePacketTimeout(); | Receives information before a timeout expires. |
receivePacketMAXTimeout(); | Same as previous function with maximum timeout. |
receivePacketTimeoutACK(); | Receives information before a timeout expires and responds with ACK. |
receivePacketMAXTimeoutACK(); | Same as previous function with maximum timeout. |
receiveAll(); | Receives all the information on air with maximum timeout. |
showFramefromPacket(); | Prints a frame received in a packet. |
Additional functions
Getting temperature
It reads the module temperature in Celsius. Negative temperatures can be expected. It stores the information in the global _temp
variable in Celsius.
Note: this feature has not a good accuracy because it requires internal calibration. Libelium recommends to use dedicated temperature sensor.
Example of use:
Related variables:
sx1272._temp
→ stores the temperature of the module
SX1272 getting temperature example:
Getting maximum allowed current supply
It reads the current supply limit of the power amplifier. This value is set to 240 mA at the beginning of the configuration when the module is switched on. Parameter range: from 0x00 to 0x1B corresponding to a range from 45 to 240 mA.
Example of use:
Related variables:
sx1272._maxCurrent
→ stores the maximum current supply of the module
SX1272 getting current supply example:
Waspmote reboot
When Waspmote is rebooted, the application code will start again, creating all the variables and objects from the beginning.
Last updated