XBEE_SETUP(3)

NAME
xbee_setup, xbee_setuplog, xbee_setupAPI, xbee_setuplogAPI

SYNOPSIS
#include <xbee.h>

int xbee_setup(char *path, int baudrate);

int xbee_setuplog(char *path, int baudrate, int logfd);

int xbee_setupAPI(char *path, int baudrate, char cmdSeq, int cmdTime);

int xbee_setuplogAPI(char *path, int baudrate, int logfd, char cmdSeq, int cmdTime);

DESCRIPTION

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!). NOTE: The file descriptor is dup()'ed before use, so you may close it immediately. Providing a value of 0 will disable the log output.

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()

RETURN VALUE
If any error occures, -1 is returned. Otherwise 0 is returned.

EXAMPLE
To setup libxbee to use /dev/ttyUSB0 at 57600 baud:
#include <xbee.h>
if (xbee_setup("/dev/ttyUSB0",57600) == -1) {
  printf("Oh no...);
  exit(1);
}

NOTE
If libxbee is compiled with DEBUG defined, then the log output will ALWAYS be enabled. If no file descriptor is provided, then stderr will be used.

AUTHOR
Attie Grande <attie@attie.co.uk>

SEE ALSO
libxbee(3), xbee_newcon(3), xbee_getpacket(3), xbee_senddata(3)