Interface with the XBee module. More...
Modules | |
xbee constants | |
These are constants used for the xbee module. | |
Xbee Functions | |
These are the public xbee functions. | |
Defines | |
#define | PORT UDR1 |
#define | FLAG (UCSR1A & (1<<RXC1)) |
Functions | |
ISR (USART1_RX_vect) | |
int8_t | xbee_basic_buf_add (uint8_t *ptr, uint8_t byte) |
uint8_t | xbee_basic_buf_get (uint8_t *ptr) |
int8_t | xbee_other_buf_add (uint8_t *ptr, uint8_t byte) |
uint8_t | xbee_other_buf_get (uint8_t *ptr) |
int8_t | check_last_receive (uint16_t source, uint8_t framenum) |
uint8_t | getStatus (uint8_t mask) |
void | setStatus (uint8_t mask, uint8_t value) |
int8_t | xbee_init () |
Initialize the XBee library. | |
int8_t | xbee_terminate () |
Uninitialize the XBee library. | |
int8_t | xbee_putc (uint8_t c) |
int16_t | xbee_getc (void) |
int8_t | xbee_getc_nb (uint8_t *c) |
int8_t | xbee_sendc (uint8_t byte) |
Send byte to the xbee in API mode. | |
int8_t | xbee_send (uint8_t *buf, uint16_t size) |
Send an array of bytes to the xbee in API mode. | |
int8_t | xbee_checksum_add (uint8_t *buf, uint8_t len, uint8_t *sum) |
Add a buffer to the checksum value. | |
int8_t | xbee_send_header (uint16_t len) |
Send a frame header to the xbee. | |
int8_t | xbee_send_read_at_command (uint8_t *command) |
int8_t | xbee_send_packet (uint8_t *packet, uint8_t len, uint16_t dest, uint8_t options, uint8_t frame) |
Send a packet to the XBee. | |
int8_t | xbee_set_pan (uint16_t id) |
Set the PAN ID for the XBee. | |
uint16_t | xbee_get_pan () |
Get the XBee's PAN ID. | |
int8_t | xbee_set_channel (uint8_t channel) |
Set the channel the XBee is currently using. | |
int8_t | xbee_get_channel (void) |
Get the channel the XBee is currently using. | |
uint16_t | xbee_get_address (void) |
Get the XBee's 16-bit address. |
Interface with the XBee module.
#define PORT UDR1 |
Interrupt for the robot. Adds bytes received from the xbee to the buffer.
int8_t check_last_receive | ( | uint16_t | source, | |
uint8_t | framenum | |||
) |
Checks if packet is a duplicate
References getStatus(), and WL_SUCCESS.
uint8_t getStatus | ( | uint8_t | mask | ) | [inline] |
status functions
Referenced by check_last_receive(), xbee_get_address(), xbee_get_channel(), xbee_get_pan(), xbee_init(), xbee_sendc(), xbee_set_channel(), and xbee_set_pan().
int8_t xbee_checksum_add | ( | uint8_t * | buf, | |
uint8_t | len, | |||
uint8_t * | sum | |||
) |
Add a buffer to the checksum value.
Adds buf to the previous checksum total
buf | a byte buffer to add to the checksum | |
len | the length of the buffer | |
sum | the previous sum |
References WL_ERROR_ARGUMENT, and WL_SUCCESS.
Referenced by wl_send().
uint16_t 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.
References getStatus(), WL_ERROR_XBEE_COMMAND_16BIT, and xbee_send_read_at_command().
Referenced by xbee_init().
int8_t xbee_get_channel | ( | void | ) |
Get the channel the XBee is currently using.
Returns the channel which the XBee is currently using.
References getStatus(), WL_ERROR_XBEE_COMMAND, and xbee_send_read_at_command().
uint16_t xbee_get_pan | ( | void | ) |
Get the XBee's PAN ID.
Get the PAN ID for the XBee.
References getStatus(), WL_ERROR_XBEE_COMMAND_16BIT, and xbee_send_read_at_command().
int16_t xbee_getc | ( | void | ) |
Returns the first byte in the buffer received from xbee. This function blocks execution until a character has been received. xbee_init must be called before this function may be used.
int8_t xbee_getc_nb | ( | uint8_t * | c | ) |
Non blocking version of xbee_getc. If a byte is present in the buffer, it is returned, otherwise -1 is returned immediately. xbee_init must be called before this function can be used.
c | The received byte. This will be set if a byte has been received. |
References WL_SUCCESS.
int8_t xbee_init | ( | void | ) |
Initialize the XBee library.
Initializes the XBee library so that other functions may be used.
References getStatus(), WL_ERROR_BAUD, WL_ERROR_INIT_ALREADY_INITD, WL_ERROR_XBEE_COMMAND_16BIT, WL_SUCCESS, xbee_basic_buf, xbee_get_address(), and xbee_set_pan().
Referenced by wl_init().
int8_t xbee_putc | ( | uint8_t | c | ) |
Sends a character to the XBee.
c | the byte to send |
References WL_SUCCESS.
Referenced by xbee_send_header(), and xbee_send_packet().
int8_t xbee_send | ( | uint8_t * | buf, | |
uint16_t | size | |||
) |
Send an array of bytes to the xbee in API mode.
Send a buffer buf of size bytes to the XBee in API mode
buf | the buffer of data to send | |
size | the number of bytes to send |
References WL_ERROR_SEND, WL_SUCCESS, and xbee_sendc().
Referenced by wl_send(), and xbee_send_packet().
int8_t xbee_send_header | ( | uint16_t | len | ) |
Send a frame header to the xbee.
Sends header information. Header information includes XBEE_FRAME_START and the packet length, as two bytes.
type | the packet type | |
len | the size in bytes of the packet data |
References WL_ERROR_SEND, WL_SUCCESS, xbee_putc(), and xbee_sendc().
Referenced by wl_send().
int8_t xbee_send_packet | ( | uint8_t * | packet, | |
uint8_t | len, | |||
uint16_t | dest, | |||
uint8_t | options, | |||
uint8_t | 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. |
References WL_ERROR_ARGUMENT, WL_ERROR_SEND, WL_SUCCESS, xbee_putc(), xbee_send(), and xbee_sendc().
int8_t xbee_send_read_at_command | ( | uint8_t * | command | ) |
Sends an AT command to read a parameter.
command | the AT command to send. For exmaple, use ID to read the PAN ID and MY to return the XBee ID. See the XBee reference guide for a complete listing. |
Referenced by xbee_get_address(), xbee_get_channel(), and xbee_get_pan().
int8_t xbee_sendc | ( | uint8_t | byte | ) |
Send byte to the xbee in API mode.
Send byte to the xbee in API mode.
byte | the byte to be sent |
References getStatus(), and WL_SUCCESS.
Referenced by wl_send(), xbee_send(), xbee_send_header(), and xbee_send_packet().
int8_t xbee_set_channel | ( | uint8_t | 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 |
References getStatus(), WL_ERROR_ARGUMENT, WL_ERROR_XBEE_COMMAND, and WL_SUCCESS.
int8_t xbee_set_pan | ( | uint16_t | id | ) |
Set the PAN ID for the XBee.
Sets the personal area network id.
id | the new personal area network (PAN) id |
References getStatus(), WL_ERROR_XBEE_COMMAND, and WL_SUCCESS.
Referenced by xbee_init().
int8_t xbee_terminate | ( | void | ) |
Uninitialize the XBee library.
Call when finished using the XBee library.
References WL_ERROR_TERMINATION_FAILED, and WL_SUCCESS.
Referenced by wl_terminate().