xbee_err xbee_conRx(struct xbee_con *con, struct xbee_pkt **retPkt, int *remainingPackets);
xbee_err xbee_conRxWait(struct xbee_con *con, struct xbee_pkt **retPkt, int *remainingPackets);
retPkt may optionally be non-NULL, in which case the next packet in the connection's buffer is returned to you. If you receive a packet from a connection, you must not forget to call xbee_pktFree(3) when you are finished with it. If retPkt is non-NULL, and a callback has been configured for the connection, then XBEE_EINVAL will be returned and neither retPkt or remainingPackets will have been updated - see xbee_conCallbackSet(3) for more information.
remainingPackets may also optionally be non-NULL. If it is non-NULL, then it will be populated with the number of packets that are currently in the connection's buffer.
When a callback is enabled, xbee_conRx() may be called with retPkt set to NULL, and remainingPackets set as non-NULL.
xbee_conRxWait() is identical to xbee_conRx(), except that it will busy-wait for upto 1 second, checking if there is a packet available.
XBEE_ENOTEXISTS will be returned if there is no packet available to retrieved.
#include <xbee.h> struct xbee *xbee; struct xbee_con *con; struct xbee_pkt *pkt; /* initialize xbee, using xbee_setup() */ /* initialize con, using xbee_conNew() */ /* receive some data for con */ if (xbee_conRx(con, &pkt, NULL) != XBEE_ENONE) return; /* use pkt */ if (xbee_pktFree(pkt) != XBEE_ENONE) return;