Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / libwireless / lib / xbee.h @ 203

History | View | Annotate | Download (2.19 KB)

1
/**
2
 * @file xbee.h
3
 * @brief Contains definitions for using the XBee
4
 *
5
 * Contains definitions for interfacing with the 
6
 * XBee module, from either a robot or a computer.
7
 * To use a robot, define ROBOT in wl_defs.h, and
8
 * to use a computer, don't define ROBOT.
9
 *
10
 * @author Brian Coltin, Colony Project, CMU Robotics Club
11
 **/
12

    
13
#ifndef XBEE_H
14
#define XBEE_H
15

    
16
/**
17
 * The port to use the XBee from on the computer.
18
 * Also, a backup port if the other is used.
19
 **/
20
#ifndef ROBOT
21
#ifndef XBEE_PORT
22
#define XBEE_PORT "/dev/ttyUSB1"
23
#endif
24
#define XBEE_PORT2 "/dev/ttyUSB0"
25
#endif
26

    
27
/**
28
 * @defgroup xbee XBee
29
 * @brief Interface with the XBee module
30
 *
31
 * Interface with the XBee module.
32
 *
33
 * @{
34
 **/
35

    
36
/*Definitions*/
37
/**@brief Unset PAN, uses XBee default **/
38
#define XBEE_PAN_DEFAULT 0xFFFF
39
/**@brief Unset channel, uses XBee default **/
40
#define XBEE_CHANNEL_DEFAULT 0
41
/**@brief Broadcast to all robots in the PAN **/
42
#define XBEE_BROADCAST 0xFFFF
43
/**@brief No special options **/
44
#define XBEE_OPTIONS_NONE 0x00
45
/**@brief Do not receive a TX_STATUS message from this packet **/
46
#define XBEE_OPTIONS_DISABLE_RESPONSE 0x01
47
/**@brief Send the packet to all PANS **/
48
#define XBEE_OPTIONS_BROADCAST_ALL_PANS 0x04
49
/**@brief A transmit status packet **/
50
#define XBEE_TX_STATUS 0x89
51
/**@brief A packet received from another XBee **/
52
#define XBEE_RX 0x81
53

    
54
/**@brief Initialize the XBee library **/
55
void xbee_lib_init(void);
56
/**@brief Uninitialize the XBee library **/
57
void xbee_terminate(void);
58
/**@brief Get a packet from the XBee **/
59
int xbee_get_packet(unsigned char* packet);
60
/**@brief Send a packet to the XBee **/
61
void xbee_send_packet(char* packet, int len, int dest,
62
        char options, char frame);
63
/**@brief Set the PAN ID for the XBee **/
64
void xbee_set_pan_id(int id);
65
/**@brief Get the XBee's PAN ID **/
66
unsigned int xbee_get_pan_id(void);
67
/**@brief Set the channel the XBee is currently using **/
68
void xbee_set_channel(int channel);
69
/**@brief Get the channel the XBee is currently using **/
70
int xbee_get_channel(void);
71
/**@brief Get the XBee's 16-bit address **/
72
unsigned int xbee_get_address(void);
73
/**@brief Set the com port on a computer, undefined on the robot**/
74
void xbee_set_com_port(char* port);
75

    
76
/**@}**/ //end defgroup
77

    
78
#endif