Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::Xbee::Xbee Class Reference

#include <Xbee.h>

Inheritance diagram for Boardcore::Xbee::Xbee:
Collaboration diagram for Boardcore::Xbee::Xbee:

Public Types

using OnFrameReceivedListener = std::function<void(APIFrame& frame)>
 

Public Member Functions

 Xbee (SPIBusInterface &bus, GpioType cs, GpioType attn, GpioType rst, long long txTimeout=DEFAULT_TX_TIMEOUT)
 Constructs a new instance of the Xbee driver.
 
 Xbee (SPIBusInterface &bus, SPIBusConfig config, GpioType cs, GpioType attn, GpioType rst, long long txTimeout=DEFAULT_TX_TIMEOUT)
 Constructs a new instance of the Xbee driver.
 
 ~Xbee ()
 
bool send (uint8_t *pkt, size_t packetLength) override
 Sends a packet. The function blocks until the packet is sent to the peripheral, but does not wait for an ACK or send confirmation from the Xbee. Thus, it always returns true.
 
ssize_t receive (uint8_t *buf, size_t bufferMaxSize) override
 Waits until a new packet is received.
 
void reset ()
 Hardware resets the Xbee.
 
void handleATTNInterrupt ()
 Signals the receive() function that there is new data available. Call this from the ATTN pin interrupt service routine, and nowhere else please.
 
void wakeReceiver (bool forceReturn=false)
 Wakes the receive function without needing an interrupt.
 
void sendATCommand (const char *cmd, uint8_t *params=nullptr, size_t paramsLength=0)
 Sends an AT Command to the Xbee (see datasheet) without waiting for a response.
 
bool sendATCommand (const char *cmd, ATCommandResponseFrame *response, uint8_t *params=nullptr, size_t paramsLength=0, unsigned int timeout=1000)
 Sends an AT Command to the Xbee and wait for a response (see datasheet)
 
void setOnFrameReceivedListener (OnFrameReceivedListener listener)
 Set the frame received listener, called each time a new APIFrame is received from the device.
 
XbeeStatus getStatus ()
 
- Public Member Functions inherited from Boardcore::Transceiver
 Transceiver ()
 
virtual ~Transceiver ()
 

Detailed Description

Definition at line 58 of file Xbee.h.

Member Typedef Documentation

◆ OnFrameReceivedListener

using Boardcore::Xbee::Xbee::OnFrameReceivedListener = std::function<void(APIFrame& frame)>

Definition at line 61 of file Xbee.h.

Constructor & Destructor Documentation

◆ Xbee() [1/2]

Boardcore::Xbee::Xbee::Xbee ( SPIBusInterface & bus,
GpioType cs,
GpioType attn,
GpioType rst,
long long txTimeout = DEFAULT_TX_TIMEOUT )

Constructs a new instance of the Xbee driver.

Parameters
busThe SPI bus where the xbee is connected
csXbee SPI Chip Select Pin
attnXbee ATTN Pin
rstXbee RST PIN
txTimeoutHow long to wait to for a TX Status

Definition at line 43 of file Xbee.cpp.

◆ Xbee() [2/2]

Boardcore::Xbee::Xbee::Xbee ( SPIBusInterface & bus,
SPIBusConfig config,
GpioType cs,
GpioType attn,
GpioType rst,
long long txTimeout = DEFAULT_TX_TIMEOUT )

Constructs a new instance of the Xbee driver.

Parameters
busThe SPI bus where the xbee is connected
configCustom SPI bus configuration
csXbee SPI Chip Select Pin
attnXbee ATTN Pin
rstXbee RST PIN
txTimeoutHow long to wait to for a TX Status

Definition at line 50 of file Xbee.cpp.

◆ ~Xbee()

Boardcore::Xbee::Xbee::~Xbee ( )

Definition at line 57 of file Xbee.cpp.

Member Function Documentation

◆ getStatus()

XbeeStatus Boardcore::Xbee::Xbee::getStatus ( )

Definition at line 163 of file Xbee.cpp.

◆ handleATTNInterrupt()

void Boardcore::Xbee::Xbee::handleATTNInterrupt ( )

Signals the receive() function that there is new data available. Call this from the ATTN pin interrupt service routine, and nowhere else please.

Definition at line 220 of file Xbee.cpp.

◆ receive()

ssize_t Boardcore::Xbee::Xbee::receive ( uint8_t * buf,
size_t bufferMaxSize )
overridevirtual

Waits until a new packet is received.

Parameters
bufBuffer to store the received packet into.
bufferMaxSizeMaximum length of the received data.
Returns
Size of the data received or -1 if failure

Implements Boardcore::Transceiver.

Definition at line 116 of file Xbee.cpp.

◆ reset()

void Boardcore::Xbee::Xbee::reset ( )

Hardware resets the Xbee.

Definition at line 170 of file Xbee.cpp.

◆ send()

bool Boardcore::Xbee::Xbee::send ( uint8_t * pkt,
size_t packetLength )
overridevirtual

Sends a packet. The function blocks until the packet is sent to the peripheral, but does not wait for an ACK or send confirmation from the Xbee. Thus, it always returns true.

Parameters
pktPointer to the packet (needs to be at least packetLength bytes).
packetLengthLength of the packet to be sent.
Returns
Always true

Implements Boardcore::Transceiver.

Definition at line 59 of file Xbee.cpp.

◆ sendATCommand() [1/2]

bool Boardcore::Xbee::Xbee::sendATCommand ( const char * cmd,
ATCommandResponseFrame * response,
uint8_t * params = nullptr,
size_t paramsLength = 0,
unsigned int timeout = 1000 )

Sends an AT Command to the Xbee and wait for a response (see datasheet)

Parameters
cmdTwo character string with the name of the command (eg "DB")
paramsOptional command parameters
paramsLengthLength in bytes of the params array
responseWhere to store the response
timeoutMaximum time to wait for the response
Returns
true if response received before the timeout, false otherwise

Definition at line 377 of file Xbee.cpp.

◆ sendATCommand() [2/2]

void Boardcore::Xbee::Xbee::sendATCommand ( const char * cmd,
uint8_t * params = nullptr,
size_t paramsLength = 0 )

Sends an AT Command to the Xbee (see datasheet) without waiting for a response.

Parameters
cmdTwo character string with the name of the command (eg "DB")
paramsOptional command parameters
paramsLengthLength in bytes of the params array

Definition at line 370 of file Xbee.cpp.

◆ setOnFrameReceivedListener()

void Boardcore::Xbee::Xbee::setOnFrameReceivedListener ( OnFrameReceivedListener listener)

Set the frame received listener, called each time a new APIFrame is received from the device.

Parameters
listenerThe listener

Definition at line 508 of file Xbee.cpp.

◆ wakeReceiver()

void Boardcore::Xbee::Xbee::wakeReceiver ( bool forceReturn = false)

Wakes the receive function without needing an interrupt.

Parameters
forceReturnWether receive(..) should return even if it has not received any data

Definition at line 208 of file Xbee.cpp.


The documentation for this class was generated from the following files: