int xbee_setup(char *path, int baudrate);
int xbee_setuplog(char *path, int baudrate, int logfd);
int xbee_setupAPI(char *path, char cmdSeq, int cmdTime);
int xbee_setuplogAPI(char *path, int baudrate, int logfd, char cmdSeq, int cmdTime);
A VERSION OF THIS FUNCTION MUST BE CALLED BEFORE ANY OTHER libxbee FUNCTION! The xbee_setup() function will setup libxbee so that it can handle an XBee. It takes 2 arguments.
The argument path is the path to the serial port that the XBee is connected to (e.g. /dev/ttyUSB0).
The baudrate is the baud rate that the local XBee is configured to run at. The following are avaliable:
1200 2400 4800 9600 19200 38400 57600 115200 - this is potentially unstable (read the XBee manual to find out why...)
Using xbee_setuplog() is exactly the same, but instead you give an open file descriptor. All log messages will be written to this file (you can use stderr or stdout if you want!).
Using xbee_setupAPI() is exactly the same, but instead you provide the 'Command Sequence' character and the 'Guard Time' that your local XBee has been configured with. libxbee will then place your XBee in API mode 2, and when you call xbee_end() it will return your XBee to its previous API mode.
Using xbee_setuplogAPI() is simply a combination of xbee_setuplog() and xbee_setupAPI()
#include <xbee.h> if (xbee_setup("/dev/ttyUSB0",57600) == -1) { printf("Oh no...); exit(1); }