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);
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.
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"
#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;