XBEE_SETUP

Section: Linux Programmer's Manual (3)
Updated: 02-Mar-2012
Index Return to Main Contents
 

NAME

xbee_setup, xbee_vsetup, xbee_validate, xbee_shutdown  

SYNOPSIS

#include <xbee.h>

xbee_err xbee_setup(struct xbee **retXbee, const char *mode, ...);

xbee_err xbee_vsetup(struct xbee **retXbee, const char *mode, va_list ap);

xbee_err xbee_validate(struct xbee *xbee);

xbee_err xbee_shutdown(struct xbee *xbee);  

DESCRIPTION

The functions xbee_setup() and xbee_vsetup() start an instance of libxbee. retXbee is the returned pointer to the libxbee instance. mode specifies which mode should be started. Three modes are currently provided and supported:

'xbee1'   the mode used for Series 1 XBee modules
'xbee2'   the mode used for Series 2 XBee modules
'xbee3'   the mode used for Series 3 XBee modules
'xbee5'   the mode used for Series 5 XBee modules (868 MHz)
'xbee6b'  the mode used for Series 6B XBee modules (Wi-Fi)
'xbeeZB'  the mode used for ZigBee XBee modules
'net'     the network client
'debug'   the debugger

Each mode can require different initialization parameters, which are provided by the ... or ap arguments. The arguments for the modes listed above are detailed below in the 'Modes' section.

xbee_validate() allows you to confirm that your handle points to a valid libxbee instance.

xbee_shutdown() will terminate all remaining connections and free all data associated with the instance of libxbee.  

Modes

'xbee1', 'xbee2', 'xbee3', 'xbee5', 'xbee6b' and 'xbeeZB' - these modes require two parameters: char *device e.g: "/dev/ttyUSB0"

int baudrate e.g: 57600

'net' - this mode required two parameters: char *hostname e.g: "localhost", "127.0.0.1"

int port e.g: 27015

'debug' - this mode required one parameter: char *target_mode e.g: "xbee1"  

Return Value

On success these functions will return XBEE_ENONE, otherwise an error number from enum xbee_errors (as specified in <xbee.h>)  

EXAMPLE

To setup libxbee with a Series 1 XBee, using /dev/ttyUSB0 at 57600 baud:

#include <xbee.h>

xbee_err ret;
struct xbee *xbee;

if ((ret = xbee_setup(&xbee, "xbee1", "/dev/ttyUSB0", 57600)) != XBEE_ENONE) {
        printf("xbee_setup(): %d - %s\n", ret, xbee_errorToStr(ret));
        return ret;
}

/* use libxbee */

if (xbee_shutdown(xbee) != XBEE_ENONE) return;
 

NOTES

When running on OSX with a USB to UART adapter, you should choose /dev/cu.usbserial-*, not /dev/tty.usbserial-*.  

AUTHOR

Attie Grande <attie@attie.co.uk>  

SEE ALSO

libxbee(3), xbee_modeGetList(3), xbee_conGetTypes(3), xbee_conNew(3), xbee_attachEOFCallback(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
Modes
Return Value
EXAMPLE
NOTES
AUTHOR
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 13:52:19 GMT, August 11, 2019