XBee

Interface with the XBee module. More...

Defines

#define XBEE_PAN_DEFAULT   0xFFFF
 Do not change the PAN.
#define XBEE_BROADCAST   0xFFFF
 Broadcast to all robots in the PAN.
#define XBEE_OPTIONS_NONE   0x00
 No special options.
#define XBEE_OPTIONS_DISABLE_RESPONSE   0x01
 Do not receive a TX_STATUS message from this packet.
#define XBEE_OPTIONS_BROADCAST_ALL_PANS   0x04
 Send the packet to all PANS.
#define XBEE_TX_STATUS   0x89
 A transmit status packet.
#define XBEE_RX   0x81
 A packet received from another XBee.

Functions

void xbee_lib_init (int pan_id)
 Initialize the XBee library.
void xbee_terminate (void)
 Uninitialize the XBee library.
int xbee_get_packet (unsigned char *packet)
 Get a packet from the XBee.
void xbee_send_packet (char *packet, int len, int dest, char options, char frame)
 Send a packet to the XBee.
void xbee_set_pan_id (int id)
 Set the PAN ID for the XBee.
unsigned int xbee_get_pan_id (void)
 Get the XBee's PAN ID.
unsigned int xbee_get_address (void)
 Get the XBee's 16-bit address.

Detailed Description

Interface with the XBee module.

Interface with the XBee module.


Function Documentation

unsigned int xbee_get_address void   ) 
 

Get the XBee's 16-bit address.

Get the 16-bit address of the XBee. This is used to specify who to send messages to and who messages are from.

Returns:
the 16-bit address of the XBee.

int xbee_get_packet unsigned char *  dest  ) 
 

Get a packet from the XBee.

Reads a packet received from the XBee. This function is non-blocking. The resulting packet is stored in dest. Only returns transmission response packets and received packets. The returned packet does not include header information or the checksum. This method also handles special packets dealt with by the XBee library, and so should be called frequently while the XBee is in use.

The first byte of the packet will be either XBEE_TX_STATUS or XBEE_RX to indicated a response to a sent message or a received message, respectively.

For a status response packet:
The first byte will be XBEE_TX_STATUS.
The second byte will be the frame number.
The third byte will be the result. 0 indicates success, and nonzero indicates that an error ocurred in transmitting the packet.

For a received packet:
The first byte will be XBEE_RX.
The second and third bytes will be the 16-bit address of the packet's sender.
The fourth byte is the signal strength.
The fifth byte is 1 if the packet were sent to a specific address, and 2 if it is a broadcast packet.

Parameters:
dest set to the packet data
Returns:
the length of the packet, or -1 if no packet is available

unsigned int xbee_get_pan_id void   ) 
 

Get the XBee's PAN ID.

Get the PAN ID for the XBee.

Returns:
the personal area network id, or XBEE_PAN_DEFAULT if it has not yet been set.

void xbee_lib_init int  pan_id  ) 
 

Initialize the XBee library.

Initializes the XBee library so that other functions may be used.

Parameters:
pan_id the PAN to join initially. Use XBEE_PAN_DEFAULT to leave the PAN as it is initially.

void xbee_send_packet char *  packet,
int  len,
int  dest,
char  options,
char  frame
 

Send a packet to the XBee.

Send the specified packet.

Parameters:
packet the packet data to send
len the number of bytes in the packet
dest the ID of the XBee to send the packet to, or XBEE_BROADCAST to send the message to all robots in the PAN.
options a combination of the flags XBEE_OPTIONS_NONE, XBEE_OPTIONS_DISABLE_RESPONSE and XBEE_OPTIONS_BROADCAST_ALL_PANS
frame the frame number to associate this packet with. This will be used to identify the response when the XBee alerts us as to whether or not our message was received.

void xbee_set_pan_id int  id  ) 
 

Set the PAN ID for the XBee.

Sets the personal area network id.

Parameters:
id the new personal area network (PAN) id

void xbee_terminate void   ) 
 

Uninitialize the XBee library.

Call when finished using the XBee library. This releases all sued resources.


Generated on Fri Sep 21 12:57:06 2007 for libwireless by  doxygen 1.4.6