BayEOS-Arduino  1.8.0_0.0.4
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
XBeeInterface Class Referenceabstract

#include <XBee.h>

Inheritance diagram for XBeeInterface:
BayXBeeInterface XBee XBeePlus BayXBee BayXBeePlus

Public Member Functions

void readPacket ()
 
bool readPacket (int timeout)
 
void readPacketUntilAvailable ()
 
void getResponse (XBeeResponse &response)
 
XBeeResponsegetResponse ()
 
void send (XBeeRequest &request)
 
uint16_t getPANID (void)
 
uint8_t parseRX16 (BayEOS &client, int rx_panid)
 
uint8_t getNextFrameId ()
 
virtual void i_begin (long baud)=0
 
virtual int i_available ()=0
 
virtual int read ()=0
 
virtual void flush ()=0
 
virtual size_t write (uint8_t val)=0
 

Protected Member Functions

void sendByte (uint8_t b, bool escape)
 
void resetResponse ()
 

Protected Attributes

XBeeResponse _response
 
bool _escape
 
uint8_t _pos
 
uint8_t b
 
uint8_t _checksumTotal
 
uint8_t _nextFrameId
 
uint8_t _responseFrameData [MAX_FRAME_DATA_SIZE]
 

Detailed Description

Primary interface for communicating with an XBee Radio. This class provides methods for sending and receiving packets with an XBee radio via the serial port. The XBee radio must be configured in API (packet) mode (AP=2) in order to use this software.

Since this code is designed to run on a microcontroller, with only one thread, you are responsible for reading the data off the serial buffer in a timely manner. This involves a call to a variant of readPacket(...). If your serial port is receiving data faster than you are reading, you can expect to lose packets. Arduino only has a 128 byte serial buffer so it can easily overflow if two or more packets arrive without a call to readPacket(...)

In order to conserve resources, this class only supports storing one response packet in memory at a time. This means that you must fully consume the packet prior to calling readPacket(...), because calling readPacket(...) overwrites the previous response.

This class creates an array of size MAX_FRAME_DATA_SIZE for storing the response packet. You may want to adjust this value to conserve memory.

Author
Andrew Rapp

Definition at line 679 of file XBee.h.

Member Function Documentation

◆ getPANID()

uint16_t XBeeInterface::getPANID ( void  )

Returns a sequential frame id between 1 and 255

Definition at line 1451 of file XBee.cpp.

◆ getResponse() [1/2]

void XBeeInterface::getResponse ( XBeeResponse response)

Starts the serial connection at the supplied baud rate

Definition at line 1250 of file XBee.cpp.

◆ getResponse() [2/2]

XBeeResponse & XBeeInterface::getResponse ( )

Returns a reference to the current response Note: once readPacket is called again this response will be overwritten!

Definition at line 1245 of file XBee.cpp.

◆ readPacket()

bool XBeeInterface::readPacket ( int  timeout)

Waits a maximum of timeout milliseconds for a response packet before timing out; returns true if packet is read. Returns false if timeout or error occurs.

Definition at line 1267 of file XBee.cpp.

◆ readPacketUntilAvailable()

void XBeeInterface::readPacketUntilAvailable ( )

Reads until a packet is received or an error occurs. Caution: use this carefully since if you don't get a response, your Arduino code will hang on this call forever!! often it's better to use a timeout: readPacket(int)

Definition at line 1260 of file XBee.cpp.

◆ send()

void XBeeInterface::send ( XBeeRequest request)

Sends a XBeeRequest (TX packet) out the serial port

Definition at line 1398 of file XBee.cpp.


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