A library with drivers for different peripherals on the LPC4088 QuickStart Board or related add-on boards.

Dependencies:   FATFileSystem

Dependents:   LPC4088test LPC4088test_ledonly LPC4088test_deleteall LPC4088_RAMtest ... more

Embed: (wiki syntax)

« Back to documentation index

XBee Class Reference

XBee Class Reference

Interface to Digi International's XBee module. More...

#include <XBee.h>

Public Types

enum  XBeeError
 

Error codes returned from public methods.

More...
enum  CallbackType {
  CbDeviceUp = 0, CbDeviceDown, CbNodeFound, CbTxStat,
  CbDataAvailable
}
 

Callback function/method types.

More...
enum  XBeeType
 

Xbee types.

More...
enum  XBeeTxStatus
 

Transmit status.

More...

Public Member Functions

 XBee (PinName tx, PinName rx, PinName reset, PinName sleep)
 Create an interface to an XBee module.
XBeeError init (XBeeType type, const char *panId)
 Initialize the XBee module and configure it to be of a specific type.
void registerCallback (void(*fptr)(void), CallbackType type)
 Register a callback function.
template<typename T >
void registerCallback (T *tptr, void(T::*mptr)(void), CallbackType type)
 Register a callback method.
void process ()
 Call this method repeatedly to process incoming data.
XBeeError getRemoteAddress (uint32_t *addrHi, uint32_t *addrLo)
 Get address of remote node.
XBeeError getRssi (uint8_t *rssi)
 Get signal strength indicator value (RSSI).
XBeeError getTxStatus (uint8_t *frameId, XBeeTxStatus *status)
 Get the transmit status.
XBeeError getData (char **data, uint8_t *len)
 Get received data.
XBeeError send (uint32_t addrHi, uint32_t addrLo, char *data, uint8_t len, uint8_t *frameId)
 Send data to a node with specified address.
XBeeError discoverNodes ()
 Send a Node Discover request.
XBeeError enterSleep ()
 Request the module to enter sleep mode.
XBeeError exitSleep ()
 Request the module to exit sleep mode.

Detailed Description

Interface to Digi International's XBee module.

The XBee S1 module has been used during testing of this interface.

Definition at line 30 of file XBee.h.


Member Enumeration Documentation

Callback function/method types.

See registerCallback()

Enumerator:
CbDeviceUp 

Device is up and ready.

CbDeviceDown 

Device is down (disconnected)

CbNodeFound 

A node has been found.

CbTxStat 

Transmit status.

CbDataAvailable 

Data is available.

Definition at line 46 of file XBee.h.

enum XBeeError

Error codes returned from public methods.

Definition at line 34 of file XBee.h.

Transmit status.

Definition at line 68 of file XBee.h.

enum XBeeType

Xbee types.

Definition at line 62 of file XBee.h.


Constructor & Destructor Documentation

XBee ( PinName  tx,
PinName  rx,
PinName  reset,
PinName  sleep 
)

Create an interface to an XBee module.

Parameters:
txUART TX line
txUART rx line
resetreset pin
sleepsleep request pin

Definition at line 50 of file XBee.cpp.


Member Function Documentation

XBee::XBeeError discoverNodes (  )

Send a Node Discover request.

All modules on the operating channel and PAN ID should respond. The responses will be reported in the CbNodeFound callback.

Definition at line 259 of file XBee.cpp.

XBee::XBeeError enterSleep (  )

Request the module to enter sleep mode.

Definition at line 268 of file XBee.cpp.

XBee::XBeeError exitSleep (  )

Request the module to exit sleep mode.

Definition at line 274 of file XBee.cpp.

XBee::XBeeError getData ( char **  data,
uint8_t *  len 
)

Get received data.

This method will only return valid data when called in the context of the CbDataAvailable callback

Parameters:
datawill point to a buffer with received data
lenwill contain the length of the received data

Definition at line 234 of file XBee.cpp.

XBee::XBeeError getRemoteAddress ( uint32_t *  addrHi,
uint32_t *  addrLo 
)

Get address of remote node.

This method will only return valid data when called in the context of the CbDataAvailable and CbNodeFound callbacks

Parameters:
addrHiTop 32 bits of address will be written to this argument
addrLoBottom 32 bits of address will be written to this argument

Definition at line 190 of file XBee.cpp.

XBee::XBeeError getRssi ( uint8_t *  rssi )

Get signal strength indicator value (RSSI).

This method will only return valid data when called in the context of the CbDataAvailable and CbNodeFound callbacks

Parameters:
rssiRSSI value will be written to this argument

Definition at line 205 of file XBee.cpp.

XBee::XBeeError getTxStatus ( uint8_t *  frameId,
XBeeTxStatus status 
)

Get the transmit status.

This method will only return valid data when called in the context of the CbTxStat callback.

Parameters:
frameIdthe frame ID will be written to this argument
statusthe status will be written to this argument

Definition at line 219 of file XBee.cpp.

XBee::XBeeError init ( XBeeType  type,
const char *  panId 
)

Initialize the XBee module and configure it to be of a specific type.

Note: This implementation will always configure the XBee module to work in API mode.

Parameters:
typethe type of this XBee node
panIdthe PAN ID to use for the XBee network. This argument must contain 4 characters representing hexadecimal values (e.g. "A1E0" means the hexadecimal value 0xA1E0);

Definition at line 82 of file XBee.cpp.

void process (  )

Call this method repeatedly to process incoming data.

Definition at line 169 of file XBee.cpp.

void registerCallback ( void(*)(void)  fptr,
CallbackType  type 
)

Register a callback function.

Parameters:
fptrCallback function to register
typeThe type of event that will trigger a call to the function.

Definition at line 105 of file XBee.h.

void registerCallback ( T *  tptr,
void(T::*)(void)  mptr,
CallbackType  type 
)

Register a callback method.

Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called
typeThe type of event that will trigger a call to the method.

Definition at line 119 of file XBee.h.

XBee::XBeeError send ( uint32_t  addrHi,
uint32_t  addrLo,
char *  data,
uint8_t  len,
uint8_t *  frameId 
)

Send data to a node with specified address.

It is also possible to broadcast a message using broadcast address (XBEE_ADDRHI_BROADCAST, XBEE_ADDRLO_BROADCAST).

Parameters:
addrHiTop 32 bits of address
addrLoBottom 32 bits of address
databuffer containing data to send
lennumber of bytes to send
frameIdthe ID of the frame will be written to this argument. The ID can then be used to match this request with the status returned in the CbTxStat callback.

Definition at line 249 of file XBee.cpp.