root / trunk / code / projects / test / test_xbee.c @ 1437
History | View | Annotate | Download (1 KB)
1 | 1432 | dsschult | #include <dragonfly_lib.h> |
---|---|---|---|
2 | #include <xbee.h> |
||
3 | |||
4 | #define ROBOT
|
||
5 | #define WL_DEBUG
|
||
6 | #define WL_DEBUG_PRINT( s ) usb_puts( S )
|
||
7 | |||
8 | extern int xbee_send_read_at_command(char* command); |
||
9 | extern int xbee_get_packet(unsigned char* dest); |
||
10 | 1437 | dsschult | extern void xbee_terminate(void); |
11 | 1432 | dsschult | |
12 | /*
|
||
13 | * This function tests the xbee, returning the results to teraterm
|
||
14 | *
|
||
15 | *
|
||
16 | */
|
||
17 | |||
18 | int testxbee(void) { |
||
19 | |||
20 | unsigned char buf[100]; |
||
21 | int i=0; |
||
22 | |||
23 | usb_init(); |
||
24 | usb_puts("usb turned on, test starting:\r\n");
|
||
25 | |||
26 | 1437 | dsschult | if (xbee_lib_init() != 0) { |
27 | usb_puts("xbee_lib_init() failed\r\n");
|
||
28 | return -1; |
||
29 | } else {
|
||
30 | usb_puts("xbee_lib__init successful\r\n");
|
||
31 | 1432 | dsschult | } |
32 | 1437 | dsschult | |
33 | 1432 | dsschult | usb_puts("\r\n\n");
|
34 | delay_ms(1000);
|
||
35 | |||
36 | // try getting xbee address
|
||
37 | xbee_send_read_at_command("MY");
|
||
38 | while(i++ < 10000) { |
||
39 | if(xbee_get_packet(buf) == 3) { |
||
40 | usb_puts("got response from xbee\r\n");
|
||
41 | //usb_puts("packet:");
|
||
42 | //usb_puts(buf);
|
||
43 | //usb_puts("|end\r\n");
|
||
44 | break; // got a response |
||
45 | } |
||
46 | } |
||
47 | 1437 | dsschult | |
48 | xbee_terminate(); |
||
49 | 1432 | dsschult | usb_puts("testxbee done\r\n\r\n");
|
50 | 1437 | dsschult | |
51 | 1432 | dsschult | return 0; |
52 | } |