Interface with the XBee module. More...
Defines | |
#define | XBEE_PAN_DEFAULT 0xFFFF |
Unset PAN, uses XBee default. | |
#define | XBEE_CHANNEL_DEFAULT 0 |
Unset channel, uses XBee default. | |
#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 | |
int | xbee_lib_init (void) |
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. | |
int | xbee_send_packet (char *packet, int len, int dest, char options, char frame) |
Send a packet to the XBee. | |
int | 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. | |
int | xbee_set_channel (int channel) |
Set the channel the XBee is currently using. | |
int | xbee_get_channel (void) |
Get the channel the XBee is currently using. | |
unsigned int | xbee_get_address (void) |
Get the XBee's 16-bit address. | |
void | xbee_set_com_port (char *port) |
Set the com port on a computer, undefined on the robot. |
Interface with the XBee module.
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.
Referenced by wl_get_xbee_id().
int xbee_get_channel | ( | void | ) |
Get the channel the XBee is currently using.
Returns the channel which the XBee is currently using.
Referenced by wl_get_channel().
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.
dest | set to the packet data |
Referenced by wl_do(), and xbee_lib_init().
unsigned int xbee_get_pan_id | ( | void | ) |
Get the XBee's PAN ID.
Get the PAN ID for the XBee.
Referenced by wl_get_pan().
int xbee_lib_init | ( | void | ) |
Initialize the XBee library.
Initializes the XBee library so that other functions may be used.
References xbee_get_packet().
Referenced by wl_init().
int xbee_send_packet | ( | char * | packet, | |
int | len, | |||
int | dest, | |||
char | options, | |||
char | frame | |||
) |
Send a packet to the XBee.
Send the specified packet.
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. |
int xbee_set_channel | ( | int | channel | ) |
Set the channel the XBee is currently using.
Set the channel the XBee is using.
channel | the channel the XBee will not use, between 0x0B and 0x1A |
Referenced by wl_set_channel().
int xbee_set_pan_id | ( | int | id | ) |
Set the PAN ID for the XBee.
Sets the personal area network id.
id | the new personal area network (PAN) id |
Referenced by wl_set_pan().
void xbee_terminate | ( | void | ) |
Uninitialize the XBee library.
Call when finished using the XBee library. This releases all sued resources.
Referenced by wl_terminate().