Xbee Arduino
Arduino Driver for Xbee
|
Implementation of XBee LR (LoRaWAN) subclass. More...
#include "xbee_lr.h"
#include "xbee_api_frames.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Functions | |
bool | XBeeLRConnected (XBee *self) |
Checks if the XBee LR module is connected to the LoRaWAN network. More... | |
bool | XBeeLRInit (XBee *self, uint32_t baudRate, void *device) |
Initializes the XBee LR module for communication. More... | |
void | XBeeLRProcess (XBee *self) |
Processes incoming data and events for the XBee LR module. More... | |
bool | XBeeLRConnect (XBee *self) |
Attempts to connect to the LoRaWAN network using the XBee LR module. More... | |
bool | XBeeLRDisconnect (XBee *self) |
Disconnects from the LoRaWAN network using the XBee LR module. More... | |
uint8_t | XBeeLRSendData (XBee *self, const void *data) |
Sends data over the network using the XBee LR module. More... | |
bool | XBeeLRSoftReset (XBee *self) |
void | XBeeLRHardReset (XBee *self) |
bool | XBeeLRSetAppEUI (XBee *self, const char *value) |
Sends the AT_AE command to set the LoRaWAN AppEUI on the XBee LR module. More... | |
bool | XBeeLRSetAppKey (XBee *self, const char *value) |
Sends the AT_AK command to set the LoRaWAN AppKey on the XBee LR module. More... | |
bool | XBeeLRSetNwkKey (XBee *self, const char *value) |
Sends the AT_NK command to set the LoRaWAN NwkKey on the XBee LR module. More... | |
bool | XBeeLRSetClass (XBee *self, const char value) |
Sends the AT_LC command to set the LoRaWAN Class on the XBee LR module. More... | |
bool | XBeeLRSetActivationMode (XBee *self, const uint8_t value) |
Sends the AT_AM command to set the LoRaWAN Activation Mode on the XBee LR module. More... | |
bool | XBeeLRSetADR (XBee *self, const uint8_t value) |
Sends the AT_AD command to set the LoRaWAN ADR on the XBee LR module. More... | |
bool | XBeeLRSetDataRate (XBee *self, const uint8_t value) |
Sends the AT_DR command to set the LoRaWAN DataRate on the XBee LR module. More... | |
bool | XBeeLRSetRegion (XBee *self, const uint8_t value) |
Sends the AT_LR command to set the LoRaWAN Region on the XBee LR module. More... | |
bool | XBeeLRSetDutyCycle (XBee *self, const uint8_t value) |
Sends the AT_DC command to set the LoRaWAN Duty Cycle on the XBee LR module. More... | |
bool | XBeeLRSetJoinRX1Delay (XBee *self, const uint32_t value) |
Sends the AT_J1 command to set the LoRaWAN Join RX1 Delay on the XBee LR module. More... | |
bool | XBeeLRSetJoinRX2Delay (XBee *self, const uint32_t value) |
Sends the AT_J2 command to set the LoRaWAN Join RX2 Delay on the XBee LR module. More... | |
bool | XBeeLRSetRX1Delay (XBee *self, const uint32_t value) |
Sends the AT_D1 command to set the LoRaWAN RX1 Delay on the XBee LR module. More... | |
bool | XBeeLRSetRX2Delay (XBee *self, const uint32_t value) |
Sends the AT_D2 command to set the LoRaWAN RX2 Delay on the XBee LR module. More... | |
bool | XBeeLRSetRX2DataRate (XBee *self, const uint8_t value) |
Sends the AT_XD command to set the LoRaWAN RX2 Data Rate on the XBee LR module. More... | |
bool | XBeeLRSetRX2Frequency (XBee *self, const uint32_t value) |
Sends the AT_XF command to set the LoRaWAN RX2 Frequency on the XBee LR module. More... | |
bool | XBeeLRSetTransmitPower (XBee *self, const uint8_t value) |
Sends the AT_PO command to set the LoRaWAN Transmit Power on the XBee LR module. More... | |
bool | XBeeLRGetDevEUI (XBee *self, uint8_t *responseBuffer, uint8_t buffer_size) |
Sends the AT_DE command to read the LoRaWAN DevEUI from the XBee LR module. More... | |
bool | XBeeLRSetChannelsMask (XBee *self, const char *value) |
Sends the AT_CM command to set the LoRaWAN Channels Mask on the XBee LR module. More... | |
void | XBeeLRHandleTransmitStatus (XBee *self, void *param) |
XBeeLR * | XBeeLRCreate (const XBeeCTable *cTable, const XBeeHTable *hTable) |
Constructor for creating an XBeeLR instance. More... | |
void | XBeeLRDestroy (XBeeLR *self) |
Variables | |
const XBeeVTable | XBeeLRVTable |
Implementation of XBee LR (LoRaWAN) subclass.
This file contains the implementation of functions specific to the XBee LR module. It includes methods for initializing, sending join requests, and handling other operations unique to the XBee LR subclass.
@license MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bool XBeeLRConnect | ( | XBee * | self | ) |
Attempts to connect to the LoRaWAN network using the XBee LR module.
This function initiates the connection process to a LoRaWAN network by sending a join request. The function is currently blocking, meaning it waits until the connection attempt is completed before returning. A future enhancement (
[in] | self | Pointer to the XBee instance. |
bool XBeeLRConnected | ( | XBee * | self | ) |
Checks if the XBee LR module is connected to the LoRaWAN network.
This function sends an AT command (AT_JS
) to the XBee LR module to query the Join Status, determining whether the module is currently connected to the LoRaWAN network. It returns true if the module is connected (i.e., has joined the network) and false otherwise. The function also handles the communication with the module and provides debug output in case of communication errors.
[in] | self | Pointer to the XBee instance. |
XBeeLR * XBeeLRCreate | ( | const XBeeCTable * | cTable, |
const XBeeHTable * | hTable | ||
) |
Constructor for creating an XBeeLR instance.
This function allocates memory for a new XBeeLR instance and initializes it with the provided callback table (cTable
) and handler table (hTable
). The function sets up the virtual table (vtable
) for XBee LR-specific operations and assigns the callback and handler tables to the instance. The newly created instance is then returned to the caller.
[in] | cTable | Pointer to the callback table containing function pointers for handling XBee events. |
[in] | hTable | Pointer to the handler table containing platform-specific function implementations. |
void XBeeLRDestroy | ( | XBeeLR * | self | ) |
bool XBeeLRDisconnect | ( | XBee * | self | ) |
Disconnects from the LoRaWAN network using the XBee LR module.
This function handles the disconnection process from a LoRaWAN network. It ensures that the XBee LR module is properly disconnected and that any necessary cleanup is performed. The function is currently blocking.
[in] | self | Pointer to the XBee instance. |
bool XBeeLRGetDevEUI | ( | XBee * | self, |
uint8_t * | responseBuffer, | ||
uint8_t | buffer_size | ||
) |
Sends the AT_DE command to read the LoRaWAN DevEUI from the XBee LR module.
This function retrieves the LoRaWAN DevEUI (Device Extended Unique Identifier) from the XBee LR module by sending the AT command AT_DE
. The function is blocking, meaning it waits for a response from the module or until a timeout occurs. If the command fails to send or the module does not respond, a debug message is printed. The DevEUI is stored in the provided response buffer.
[in] | self | Pointer to the XBee instance. |
[out] | responseBuffer | Buffer to store the retrieved DevEUI. |
[in] | buffer_size | Size of the response buffer (should be at least 17 bytes). |
void XBeeLRHandleTransmitStatus | ( | XBee * | self, |
void * | param | ||
) |
void XBeeLRHardReset | ( | XBee * | self | ) |
bool XBeeLRInit | ( | XBee * | self, |
uint32_t | baudRate, | ||
void * | device | ||
) |
Initializes the XBee LR module for communication.
This function initializes the XBee LR module by setting up the necessary serial communication parameters, such as the baud rate and device path. It relies on platform-specific UART initialization provided by the hardware abstraction layer. The function returns true if initialization is successful.
[in] | self | Pointer to the XBee instance. |
[in] | baudrate | The baud rate for serial communication. |
[in] | device | The path to the serial device (e.g., "/dev/ttyUSB0"). |
void XBeeLRProcess | ( | XBee * | self | ) |
Processes incoming data and events for the XBee LR module.
This function must be called continuously in the main loop of the application. It handles the reception and processing of API frames from the XBee LR module. The function checks for incoming frames, and if a frame is successfully received, it is processed accordingly.
[in] | self | Pointer to the XBee instance. |
uint8_t XBeeLRSendData | ( | XBee * | self, |
const void * | data | ||
) |
Sends data over the network using the XBee LR module.
This function constructs and sends a data packet over the network using an XBee LR module. The function is currently blocking, meaning it waits until the data is fully transmitted before returning. A future enhancement (
[in] | self | Pointer to the XBee instance. |
[in] | data | Pointer to the data to be sent, encapsulated in an XBeeLRPacket_t structure. |
bool XBeeLRSetActivationMode | ( | XBee * | self, |
const uint8_t | value | ||
) |
bool XBeeLRSetADR | ( | XBee * | self, |
const uint8_t | value | ||
) |
bool XBeeLRSetAppEUI | ( | XBee * | self, |
const char * | value | ||
) |
Sends the AT_AE command to set the LoRaWAN AppEUI on the XBee LR module.
This function configures the LoRaWAN AppEUI (Application Identifier) on the XBee LR module by sending the AT command AT_AE
with the specified AppEUI value. The function is blocking, meaning it waits for a response from the module or until a timeout occurs. If the command fails to send or the module does not respond, a debug message is printed.
[in] | self | Pointer to the XBee instance. |
[in] | value | The AppEUI to be set, provided as a string. |
bool XBeeLRSetAppKey | ( | XBee * | self, |
const char * | value | ||
) |
Sends the AT_AK command to set the LoRaWAN AppKey on the XBee LR module.
This function configures the LoRaWAN AppKey (Application Key) on the XBee LR module by sending the AT command AT_AK
with the specified AppKey value. The function is blocking, meaning it waits for a response from the module or until a timeout occurs. If the command fails to send or the module does not respond, a debug message is printed.
[in] | self | Pointer to the XBee instance. |
[in] | value | The AppKey to be set, provided as a string. |
bool XBeeLRSetChannelsMask | ( | XBee * | self, |
const char * | value | ||
) |
Sends the AT_CM command to set the LoRaWAN Channels Mask on the XBee LR module.
This function configures the Channels Mask for the LoRaWAN network on the XBee LR module by sending the AT_CM command. The Channels Mask specifies the sub-bands that are enabled for communication. The function checks the command response to verify if the mask was successfully set.
[in] | self | Pointer to the XBee instance. |
[in] | value | Pointer to a null-terminated string representing the Channels Mask in hexadecimal format. |
bool XBeeLRSetClass | ( | XBee * | self, |
const char | value | ||
) |
Sends the AT_LC command to set the LoRaWAN Class on the XBee LR module.
This function configures the LoRaWAN Class on the XBee LR module by sending the AT command AT_LC
with the specified Class value. The function is blocking, meaning it waits for a response from the module or until a timeout occurs. If the command fails to send or the module does not respond, a debug message is printed.
[in] | self | Pointer to the XBee instance. |
[in] | value | The Class to be set, provided as a char. 'A','B','C' |
bool XBeeLRSetDataRate | ( | XBee * | self, |
const uint8_t | value | ||
) |
bool XBeeLRSetDutyCycle | ( | XBee * | self, |
const uint8_t | value | ||
) |
bool XBeeLRSetJoinRX1Delay | ( | XBee * | self, |
const uint32_t | value | ||
) |
bool XBeeLRSetJoinRX2Delay | ( | XBee * | self, |
const uint32_t | value | ||
) |
bool XBeeLRSetNwkKey | ( | XBee * | self, |
const char * | value | ||
) |
Sends the AT_NK command to set the LoRaWAN NwkKey on the XBee LR module.
This function configures the LoRaWAN NwkKey (Network Key) on the XBee LR module by sending the AT command AT_NK
with the specified NwkKey value. The function is blocking, meaning it waits for a response from the module or until a timeout occurs. If the command fails to send or the module does not respond, a debug message is printed.
[in] | self | Pointer to the XBee instance. |
[in] | value | The NwkKey to be set, provided as a string. |
bool XBeeLRSetRegion | ( | XBee * | self, |
const uint8_t | value | ||
) |
bool XBeeLRSetRX1Delay | ( | XBee * | self, |
const uint32_t | value | ||
) |
bool XBeeLRSetRX2DataRate | ( | XBee * | self, |
const uint8_t | value | ||
) |
bool XBeeLRSetRX2Delay | ( | XBee * | self, |
const uint32_t | value | ||
) |
bool XBeeLRSetRX2Frequency | ( | XBee * | self, |
const uint32_t | value | ||
) |
bool XBeeLRSetTransmitPower | ( | XBee * | self, |
const uint8_t | value | ||
) |
bool XBeeLRSoftReset | ( | XBee * | self | ) |
const XBeeVTable XBeeLRVTable |