Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / test / test_xbee.c @ 1437

History | View | Annotate | Download (1 KB)

1
#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
extern void xbee_terminate(void);
11

    
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
  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
  }
32
 
33
        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
  
48
  xbee_terminate();
49
  usb_puts("testxbee done\r\n\r\n");
50
    
51
        return 0;
52
}