Xbee Arduino
Arduino Driver for Xbee
Loading...
Searching...
No Matches
xbee.h File Reference

Header file for the XBee class. More...

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include "config.h"
#include "port.h"
Include dependency graph for xbee.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  XBeeVTable
 
struct  XBeeHTable
 
struct  XBeeCTable
 
struct  XBee
 

Typedefs

typedef struct XBee XBee
 Represents an XBee device instance. More...
 

Functions

bool XBeeInit (XBee *self, uint32_t baudrate, void *device)
 Initializes the XBee module. More...
 
bool XBeeConnect (XBee *self)
 Connects the XBee to the network. More...
 
bool XBeeDisconnect (XBee *self)
 Disconnects the XBee from the network. More...
 
uint8_t XBeeSendData (XBee *self, const void *)
 Request XBee to send data over network. More...
 
bool XBeeSoftReset (XBee *self)
 Performs a soft reset of the XBee module. More...
 
void XBeeHardReset (XBee *self)
 Performs a hard reset of the XBee module. More...
 
void XBeeProcess (XBee *self)
 Calls the XBee subclass's process implementation. More...
 
bool XBeeConnected (XBee *self)
 Checks if the XBee module is connected to the network. More...
 
bool XBeeWriteConfig (XBee *self)
 Sends the ATWR command to write the current configuration to the XBee module's non-volatile memory. More...
 
bool XBeeApplyChanges (XBee *self)
 Sends the ATAC command to apply pending configuration changes on the XBee module. More...
 
bool XBeeSetAPIOptions (XBee *self, const uint8_t value)
 Sends the AT_AO command to set API Options. More...
 

Detailed Description

Header file for the XBee class.

This file defines the interface for the XBee class, including the necessary functions, data structures, and constants required to interact with XBee modules using the API frame format. It provides prototypes for initializing the module, sending and receiving data, and handling AT commands.

Version
1.0
Date
2024-08-08

@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.

Author
Felix Galindo @contact felix.nosp@m..gal.nosp@m.indo@.nosp@m.digi.nosp@m..com

Typedef Documentation

◆ XBee

Represents an XBee device instance.

This structure contains the necessary methods for interacting with an XBee module, including connecting, sending data, and receiving data. Contains function pointers for XBee subclass specific operations.

Function Documentation

◆ XBeeApplyChanges()

bool XBeeApplyChanges ( XBee self)

Sends the ATAC command to apply pending configuration changes on the XBee module.

This function sends the ATAC command using an API frame to apply any pending configuration changes on the XBee module. The function waits for a response from the module to confirm that the command was successful. If the command fails or the module does not respond, a debug message is printed.

Parameters
[in]selfPointer to the XBee instance.
Returns
bool Returns true if the changes were successfully applied, otherwise false.

◆ XBeeConnect()

bool XBeeConnect ( XBee self)

Connects the XBee to the network.

This function connects to the network by calling the XBee subclass specific connection implementation provided by the XBee subclass. This is a blocking function.

Parameters
[in]selfPointer to the XBee instance.
Returns
True if the connection is successful, otherwise false.

◆ XBeeConnected()

bool XBeeConnected ( XBee self)

Checks if the XBee module is connected to the network.

This function calls the connected method defined in the XBee subclass's virtual table (vtable) to determine if the XBee module is currently connected to the network. It returns true if the module is connected, otherwise false.

Parameters
[in]selfPointer to the XBee instance.
Returns
bool Returns true if the XBee module is connected, otherwise false.

◆ XBeeDisconnect()

bool XBeeDisconnect ( XBee self)

Disconnects the XBee from the network.

This function closes the connection by calling the platform-specific close implementation provided by the XBee subclass. This is a blocking function.

Parameters
[in]selfPointer to the XBee instance.
Returns
True if the disconnection is successful, otherwise false.

◆ XBeeHardReset()

void XBeeHardReset ( XBee self)

Performs a hard reset of the XBee module.

This function invokes the hard_reset method defined in the XBee subclass's virtual table (vtable) to perform a hard reset of the XBee module. A hard reset usually involves a full power cycle or reset through rst pin, resetting the module completely.

Parameters
[in]selfPointer to the XBee instance.
Returns
void This function does not return a value.

◆ XBeeInit()

bool XBeeInit ( XBee self,
uint32_t  baudRate,
void *  device 
)

Initializes the XBee module.

This function initializes the XBee module by setting the initial frame ID counter and calling the XBee subclass specific initialization routine.

Parameters
[in]selfPointer to the XBee instance.
[in]baudrateBaud rate for the serial communication.
[in]devicePath to the serial device (e.g., "/dev/ttyUSB0").
Returns
True if initialization is successful, otherwise false.

◆ XBeeProcess()

void XBeeProcess ( XBee self)

Calls the XBee subclass's process implementation.

This function invokes the process method defined in the XBee subclass's virtual table (vtable). It is responsible for processing any ongoing tasks or events related to the XBee module and must be called continuously in the application's main loop to ensure proper operation.

Parameters
[in]selfPointer to the XBee instance.
Returns
void This function does not return a value.

◆ XBeeSendData()

uint8_t XBeeSendData ( XBee self,
const void *  data 
)

Request XBee to send data over network.

This function sends data over the network by calling the XBee subclass specific send data implementation provided by the XBee subclass. This is a blocking function.

Parameters
[in]selfPointer to the XBee instance.
Returns
xbee_deliveryStatus_t, 0 if successful

◆ XBeeSetAPIOptions()

bool XBeeSetAPIOptions ( XBee self,
const uint8_t  value 
)

Sends the AT_AO command to set API Options.

This function configures the API Options on the XBee module by sending the AT command AT_AO with the specified API Options 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.

Parameters
[in]selfPointer to the XBee instance.
[in]valueThe API Options to be set, provided as a string.
Returns
bool Returns true if the API Options was successfully set, otherwise false.

◆ XBeeSoftReset()

bool XBeeSoftReset ( XBee self)

Performs a soft reset of the XBee module.

This function invokes the soft_reset method defined in the XBee subclass's virtual table (vtable) to perform a soft reset of the XBee module. A soft reset typically involves resetting the module's state without a full power cycle.

Parameters
[in]selfPointer to the XBee instance.
Returns
bool Returns true if the soft reset is successful, otherwise false.

◆ XBeeWriteConfig()

bool XBeeWriteConfig ( XBee self)

Sends the ATWR command to write the current configuration to the XBee module's non-volatile memory.

This function sends the ATWR command using an API frame to write the current configuration settings to the XBee module's non-volatile memory. The function waits for a response from the module to confirm that the command was successful. If the command fails or the module does not respond, a debug message is printed.

Parameters
[in]selfPointer to the XBee instance.
Returns
bool Returns true if the configuration was successfully written, otherwise false.