Hiroshi Yamaguchi / XBee 1.0
Embed: (wiki syntax)

« Back to documentation index

XBee Class Reference

XBee Class Reference

class for XBee module API mode interface More...

#include <XBee.h>

Public Types

enum  FrameType {
  None = 0, ATCommandResponse, ModemStatus, ZigBeeTransmitStatus,
  ZigBeeReceivePacket, ZigBeeExplicitRxIndicator, ZigBeeIODataSampleRxIndicator, XBeeSensorReadIndicator,
  NodeIdentificationIndicator, RemoteCommandResponse, Other
}
 

Frame type declaration for XBee API frames.

More...
enum  ValueType {
  FrameID, ATCommand, Status, CommandData,
  Address16, Address64, RetryCount, DeliveryStatus,
  DiscoveryStatus, ReceiveOptions, ReceivedData, RawData
}
 

Value type declarations for retrieving frame data contents.

More...

Public Member Functions

 XBee (Serial &ser, int apiMode=2, bool debug=false)
 creates an XBee interface object.
 XBee (PinName tx, PinName rx, int apiMode=2, bool debug=false)
 creates an XBee interface object.
 XBee (Serial &ser, Serial &mon, int apiMode=2, bool debug=false)
 creates an XBee interface object.
 XBee (PinName tx, PinName rx, Serial &mon, int apiMode=2, bool debug=false)
 creates an XBee interface object.
bool init (float timeout=15.0)
 initializes XBee module.
void setDestination (XBeeAddress64 address64, XBeeAddress16 address16=0xFFFE)
 sets destination addresses.
void setDestination (uint64_t address64, uint16_t address16=0xFFFE)
 sets destination addresses.
void setDestination (char address64[], char address16[])
 sets destination addresses.
void sendCommand (const char *command, int8_t param, bool queue=false)
 sends an AT command.
void sendCommand (const char *command, const uint8_t *param=0, int param_length=0, bool queue=false)
 sends an AT command.
void sendRemoteCommand (const char *command, int8_t param)
 sends a remote AT command.
void sendRemoteCommand (const char *command, const uint8_t *param=0, int param_length=0, char options=0x02)
 sends a remote AT command.
void * executeCommand (const char *command, int8_t param)
 executes an AT command and gets the result.
void * executeCommand (const char *command, const uint8_t *param=0, int laram_length=0)
 executes an AT command and gets the result.
bool send (const char *data, int length, bool confirm)
 sends data to the XBee(s) at the destination address.
bool sendConfirm (const char *data, int length)
 sends data and confirm the transmit status.
int printf (const char *format,...)
 sends data to the destination using printf format.
FrameType receive (float timeout=3.0)
 receives data frame from the XBee module.
bool scan (XBeeFrameID &id)
 scan received data
bool scan (ValueType type, char *value, int maxlength=1, int *length=0)
 scan received data according to the specified format.
int getFirmwareVersion ()
 gets the XBee firmware version.
char getFrameID ()
 gets the current frame ID.
void setDebug (bool debug)
 sets to run in debug mode.
void dump ()
 displays received data in dump format.
void dumpAll ()
 displays the internal data fields and receive buffer in dump format.
 operator bool ()
 operator overloading for testing XBee modem connection status.

Detailed Description

class for XBee module API mode interface

Definition at line 40 of file XBee.h.


Member Enumeration Documentation

enum FrameType

Frame type declaration for XBee API frames.

Enumerator:
None 

Empty data.

ATCommandResponse 

AT Command Response API frame.

ModemStatus 

Modem Status API frame.

ZigBeeTransmitStatus 

ZigBee Transmit Status API frame.

ZigBeeReceivePacket 

ZigBee Receive Packet API frame.

ZigBeeExplicitRxIndicator 

ZigBee Explicit Rx Indicator API frame.

ZigBeeIODataSampleRxIndicator 

ZigBee I/O Data Sample Rx Indicator API frame.

XBeeSensorReadIndicator 

XBee Sensor Read Indicator API frame.

NodeIdentificationIndicator 

Node Identification Indicator API frame.

RemoteCommandResponse 

Remote Command Response API frame.

Other 

Unknown API frame.

Definition at line 46 of file XBee.h.

enum ValueType

Value type declarations for retrieving frame data contents.

Enumerator:
FrameID 

Frame ID.

ATCommand 

AT command name.

Status 

Status.

CommandData 

Command data.

Address16 

16 bit address

Address64 

64 bit address

RetryCount 

Retry count.

DeliveryStatus 

Delivery status.

DiscoveryStatus 

Discovery status.

ReceiveOptions 

Receive option.

ReceivedData 

Received data.

RawData 

Raw data.

Definition at line 106 of file XBee.h.


Constructor & Destructor Documentation

XBee ( Serial &  ser,
int  apiMode = 2,
bool  debug = false 
)

creates an XBee interface object.

Parameters:
serSerial object through which XBee module is connected to mbed
apiModeAPI mode either 1 or 2 (use escape; default)
debugdisplay debugging (I/O state) information through LEDs

Definition at line 25 of file XBee.cpp.

XBee ( PinName  tx,
PinName  rx,
int  apiMode = 2,
bool  debug = false 
)

creates an XBee interface object.

Parameters:
txTX pin connected to XBee
rxRX pin connected to XBee
apiModeAPI mode either 1 or 2 (use escape; default)
debugdisplay debugging (I/O state) information through LEDs

Definition at line 32 of file XBee.cpp.

XBee ( Serial &  ser,
Serial &  mon,
int  apiMode = 2,
bool  debug = false 
)

creates an XBee interface object.

Parameters:
serSerial object through which XBee module is connected to mbed
monalternate Serial object for monitoring (use serial ports other than USBTX/USBRX)
apiModeAPI mode either 1 or 2 (use escape; default)
debugdisplay debugging (I/O state) information through LEDs

Definition at line 39 of file XBee.cpp.

XBee ( PinName  tx,
PinName  rx,
Serial &  mon,
int  apiMode = 2,
bool  debug = false 
)

creates an XBee interface object.

Parameters:
txTX pin connected to XBee
rxRX pin connected to XBee
monalternate Serial object for monitoring (use serial ports other than USBTX/USBRX)
apiModeAPI mode either 1 or 2 (use escape; default)
debugdisplay debugging (I/O state) information through LEDs

Definition at line 46 of file XBee.cpp.


Member Function Documentation

void dump (  )

displays received data in dump format.

Definition at line 26 of file Dump.cpp.

void dumpAll (  )

displays the internal data fields and receive buffer in dump format.

Definition at line 122 of file Dump.cpp.

void * executeCommand ( const char *  command,
const uint8_t *  param = 0,
int  laram_length = 0 
)

executes an AT command and gets the result.

Parameters:
commandAT command char string
paramparameter to the AT command (pointer to byte array)
param_lengthparameter length in bytes
Returns:
pointer to the command result, if the result is a number (char, short, long, long long), the address to the number will be returned; otherwise the address to the byte array containing the command response will be returned.

Definition at line 146 of file XBee.cpp.

void * executeCommand ( const char *  command,
int8_t  param 
)

executes an AT command and gets the result.

Parameters:
commandAT command char string
paramparameter to the AT command
Returns:
pointer to the command result, if the result is a number (char, short, long, int64_t), the address to the number will be returned; otherwise the address to the byte array containing the command response will be returned.

Definition at line 100 of file XBee.cpp.

int getFirmwareVersion (  )

gets the XBee firmware version.

Returns:
XBee firmwre version in int (unsigned short value)

Definition at line 177 of file XBee.cpp.

char getFrameID (  )

gets the current frame ID.

Returns:
frame ID number being used in the next send request

Definition at line 96 of file XBee.cpp.

bool init ( float  timeout = 15.0 )

initializes XBee module.

issues VR command to test XBee modem connection

Returns:
true if initialization succeeded, false otherwise

Definition at line 53 of file XBee.cpp.

operator bool (  )

operator overloading for testing XBee modem connection status.

Returns:
false if XBee modem connection has an error

Definition at line 92 of file XBee.cpp.

int printf ( const char *  format,
  ... 
)

sends data to the destination using printf format.

Parameters:
formatprintf format string, followed by corresponding arguments
Returns:
the number of charancters sent, or negative if error occurred

Definition at line 161 of file Send.cpp.

XBee::FrameType receive ( float  timeout = 3.0 )

receives data frame from the XBee module.

Parameters:
timeoutseconds bofer time out
Returns:
FrameType of the received frame data

Definition at line 30 of file Receive.cpp.

bool scan ( XBeeFrameID &  id )

scan received data

Parameters:
dataXBeeDataType data to be scanned
trueif scan succeeded, false otherwise

Definition at line 378 of file XBee.h.

bool scan ( ValueType  type,
char *  value,
int  maxlength = 1,
int *  length = 0 
)

scan received data according to the specified format.

Parameters:
typeValueType of the data to be scanned
valuepointer to the byte array to store the scanned value
maxlengthmax size of the value in bytes
lengthpointer to an int to receive the actual data length
trueif scan succeeded, false otherwise

Definition at line 25 of file Scan.cpp.

bool send ( const char *  data,
int  length,
bool  confirm = true 
)

sends data to the XBee(s) at the destination address.

Parameters:
dataaddress to the data (byte array)
lengthdata length in bytes
confirmif true, checks the transmission status frame and returns the result

Definition at line 134 of file Send.cpp.

void sendCommand ( const char *  command,
const uint8_t *  param = 0,
int  param_length = 0,
bool  queue = false 
)

sends an AT command.

Parameters:
commandAT command char string
paramparameter to the AT command (pointer to byte array)
param_lengthparameter length in bytes
queuetrue if command paramter is to be queued

Definition at line 72 of file Send.cpp.

void sendCommand ( const char *  command,
int8_t  param,
bool  queue = false 
)

sends an AT command.

Parameters:
commandAT command char string
paramparameter to the AT command

Definition at line 26 of file Send.cpp.

bool sendConfirm ( const char *  data,
int  length 
)

sends data and confirm the transmit status.

Parameters:
dataaddress to the data (byte array)
lengthdata length in bytes
Returns:
true if sent successfully, false otherwise (either timeout or send error occurred)

Definition at line 157 of file Send.cpp.

void sendRemoteCommand ( const char *  command,
int8_t  param 
)

sends a remote AT command.

sends an AT command to the XBee(s) at the destination address

Parameters:
commandAT command char string
paramparameter to the AT command (pointer to byte array)
param_lengthparameter length in bytes
optionsremote command options

Definition at line 80 of file Send.cpp.

void sendRemoteCommand ( const char *  command,
const uint8_t *  param = 0,
int  param_length = 0,
char  options = 0x02 
)

sends a remote AT command.

sends an AT command to the XBee(s) at the destination address

Parameters:
commandAT command char string
paramparameter to the AT command (pointer to byte array)
param_lengthparameter length in bytes
optionsremote command options

Definition at line 126 of file Send.cpp.

void setDebug ( bool  debug )

sets to run in debug mode.

Parameters:
debugtrue to display debugging information

Definition at line 194 of file XBee.cpp.

void setDestination ( uint64_t  address64,
uint16_t  address16 = 0xFFFE 
)

sets destination addresses.

Parameters:
address6464-bit destination address in uint64_t
address1616-bit destination address in uint16_t

Definition at line 79 of file XBee.cpp.

void setDestination ( char  address64[],
char  address16[] 
)

sets destination addresses.

Parameters:
address6464-bit destination address in bytes (big endian)
address1616-bit destination address in bytes

Definition at line 86 of file XBee.cpp.

void setDestination ( XBeeAddress64  address64,
XBeeAddress16  address16 = 0xFFFE 
)

sets destination addresses.

Parameters:
address64XBeeAddress64 type address
address16XBeeAddress16 type address (optional)

Definition at line 75 of file XBee.cpp.