# XBEE_SETUP

Section: Linux Programmer's Manual (3)
Updated: 2009-11-01
Index Return to Main Contents

## NAME

xbee_setup

## 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, 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!).

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);
    }

## AUTHOR

Attie Grande <attie@attie.co.uk>

## SEE ALSO

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

## Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
EXAMPLE
AUTHOR
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 00:08:23 GMT, March 30, 2011