xbee_err xbee_attachEOFCallback(struct xbee *xbee, void (*eofCallback)(struct xbee *xbee, void *rxInfo));
xbee_attachEOFCallback() allows you to be notified if an EOF occurs on the device. An EOF can occur if a USB Serial Adaptor is unplugged, or if the network server closes the connection. It is useful to know that an EOF has occured so that you can take action (e.g: warn the user).
#include <xbee.h> void eek_eof(struct xbee *xbee, void *rxInfo) { printf("device failed - EOF\n"); xbee_shutdown(xbee); } struct xbee *xbee; /* initialize xbee, using xbee_setup() */ if (xbee_attachEOFCallback(xbee, eek_eof) != XBEE_ENONE) { /* alert of error */ }