Wireless definitions. More...
Data Structures | |
struct | PacketGroupHandler |
Functions | |
int | wl_init (void) |
Initialize the wireless library. | |
void | wl_terminate (void) |
Uninitialize the wireless library. | |
void | wl_do (void) |
Perform wireless library functionality. | |
void | wl_register_packet_group (PacketGroupHandler *h) |
Register a packet group with the wireless library. | |
void | wl_unregister_packet_group (PacketGroupHandler *h) |
Unregister a packet group with the wireless library. | |
int | wl_send_robot_to_robot_global_packet (char group, char type, char *data, int len, int dest, char frame) |
Send a packet to a specific robot in any PAN. | |
int | wl_send_robot_to_robot_packet (char group, char type, char *data, int len, int dest, char frame) |
Send a packet to a specific robot in our PAN. | |
int | wl_send_global_packet (char group, char type, char *data, int len, char frame) |
Send a packet to all robots. | |
void | wl_send_pan_packet (char group, char type, char *data, int len, char frame) |
Send a packet to all robots in our PAN. | |
int | wl_set_pan (int pan) |
Set the PAN we are using. | |
int | wl_get_pan (void) |
Get the PAN we are using. | |
int | wl_set_channel (int channel) |
Set the channel we are using. | |
int | wl_get_channel (void) |
Get the channel we are using. | |
int | wl_get_xbee_id (void) |
Get the 16-bit address of the XBee module. | |
void | wl_set_com_port (char *port) |
Set the com port on a computer, undefined on the robot. |
Wireless definitions.
Contains functions and definitions for dealing with wireless functionality.
The wireless library provides a modular method for dealing with wireless packets, by allowing packet groups to be registered. A packet group is a collection of packets which share a packet group code. Each packet in the group also has a type. A packet group code and type are sent with each packet. When a packet with a group code registered in the wireless library is received, the corresponding event handler is called. The event handler uses the packet type and other information stored in the packet to respond.
This architecture allows different wireless functionality to be defined and handled separately, making it simpler and more efficient to take advantage of the XBee's wireless functionality.
void wl_do | ( | void | ) |
Perform wireless library functionality.
Performs wireless library functionality. This function must be called frequently for wireless to perform effectively. This function will call timeout handlers, as well as received packet and transmit status handlers.
References PacketGroupHandler::handle_receive, PacketGroupHandler::handle_response, xbee_get_packet(), XBEE_RX, and XBEE_TX_STATUS.
Referenced by wl_basic_do_default().
int wl_get_channel | ( | void | ) |
Get the channel we are using.
Get the channel the XBee is part of.
References xbee_get_channel().
int wl_get_pan | ( | void | ) |
Get the PAN we are using.
Get the PAN the XBee is currently part of.
References xbee_get_pan_id().
int wl_get_xbee_id | ( | void | ) |
Get the 16-bit address of the XBee module.
Returns the 16-bit address of the XBee module.
References xbee_get_address().
Referenced by wl_token_get_my_sensor_reading(), wl_token_get_sensor_reading(), and wl_token_ring_register().
int wl_init | ( | void | ) |
Initialize the wireless library.
Initializes the wireless library. Must be called before any other function.
wl_port | File descriptor for wireless port, or NULL for default. |
References WL_MAX_PACKET_GROUPS, and xbee_lib_init().
Referenced by wl_basic_init().
void wl_register_packet_group | ( | PacketGroupHandler * | h | ) |
Register a packet group with the wireless library.
Register a packet group with the wireless library. The event handlers in the packet group will be called whenever an event dealing with the packet group's group code occurs.
h | the PacketGroupHandler to register |
References PacketGroupHandler::groupCode, and WL_MAX_PACKET_GROUPS.
Referenced by wl_basic_register_handler(), wl_error_register(), and wl_token_ring_register().
int wl_send_global_packet | ( | char | group, | |
char | type, | |||
char * | data, | |||
int | len, | |||
char | frame | |||
) |
Send a packet to all robots.
Send a packet to all XBees in all PANs.
group | the packet group | |
type | the packet type | |
data | the packet data | |
len | the packet length in bytes | |
frame | the frame number to see with a TX_STATUS response |
References XBEE_BROADCAST, and XBEE_OPTIONS_BROADCAST_ALL_PANS.
Referenced by wl_basic_send_global_packet(), wl_error_send_string(), and wl_token_ring_join().
void wl_send_pan_packet | ( | char | group, | |
char | type, | |||
char * | data, | |||
int | len, | |||
char | frame | |||
) |
Send a packet to all robots in our PAN.
Send a packet to all XBee's in the same PAN.
group | the packet group | |
type | the packet type | |
data | the packet data | |
len | the packet length in bytes | |
frame | the frame number to see with a TX_STATUS response |
References XBEE_BROADCAST, and XBEE_OPTIONS_NONE.
int wl_send_robot_to_robot_global_packet | ( | char | group, | |
char | type, | |||
char * | data, | |||
int | len, | |||
int | dest, | |||
char | frame | |||
) |
Send a packet to a specific robot in any PAN.
Send a packet to a specific XBee without specifying a PAN.
group | the packet group | |
type | the packet type | |
data | the packet data | |
len | the packet length in bytes | |
dest | the 16-bit address of the XBee to send the packet to | |
frame | the frame number to see with a TX_STATUS response |
References XBEE_OPTIONS_BROADCAST_ALL_PANS.
Referenced by wl_basic_send_robot_packet().
int wl_send_robot_to_robot_packet | ( | char | group, | |
char | type, | |||
char * | data, | |||
int | len, | |||
int | dest, | |||
char | frame | |||
) |
Send a packet to a specific robot in our PAN.
Send a packet to a specific XBee in the same PAN.
group | the packet group | |
type | the packet type | |
data | the packet data | |
len | the packet length in bytes | |
dest | the 16-bit address of the XBee to send the packet to | |
frame | the frame number to see with a TX_STATUS response |
References XBEE_OPTIONS_NONE.
int wl_set_channel | ( | int | channel | ) |
Set the channel we are using.
Set the channel the XBee is listening to.
channel | the new channel to join |
References xbee_set_channel().
int wl_set_pan | ( | int | pan | ) |
Set the PAN we are using.
Set the PAN for the XBee to join.
pan | the new PAN |
References xbee_set_pan_id().
void wl_terminate | ( | void | ) |
Uninitialize the wireless library.
Uninitializes the wireless library.
References PacketGroupHandler::unregister, WL_MAX_PACKET_GROUPS, and xbee_terminate().
void wl_unregister_packet_group | ( | PacketGroupHandler * | h | ) |
Unregister a packet group with the wireless library.
Unregister a packet group from the wireless library.
h | the packet group to remove |
References PacketGroupHandler::groupCode, and PacketGroupHandler::unregister.
Referenced by wl_error_unregister(), and wl_token_ring_unregister().