int xbee_hasdigital(xbee_pkt *pkt, int sample, int input);
int xbee_getdigital(xbee_pkt *pkt, int sample, int input);
The xbee_getdigital() function will read the packet and return the sample value for the specified input.
They both take 3 arguments, with the same purposes.
The argument pkt points to a packet that was previously retrieved with xbee_getpacket()
The argument sample selects the sample within the packet to use.
The argument input specifies which input you are interested in testing.
The xbee_getdigital() function will return 1 if the provided packet has sample data for the specified input and the sample was HIGH. A 0 will be returned if the sample was LOW, or the packet does not contain sample data.
#include <xbee.h> xbee_pkt *pkt; if ((pkt = xbee_getpacket(con)) != NULL) { if (xbee_hasdigital(pkt,0,0)) { printf("D0 read %d,xbee_getdigital(pkt,0)); } else { printf("No D0 data); } free(pkt); }