int main(void) { void *d; struct xbee *xbee; struct xbee_con *con; struct xbee_conAddress address; xbee_err ret; if ((ret = xbee_setup(&xbee, "xbee1", "/dev/ttyUSB0", 9600)) != XBEE_ENONE) { printf("ret: %d (%s)\n", ret, xbee_errorToStr(ret)); return ret; } memset(&address, 0, sizeof(address)); address.addr64_enabled = 1; address.addr64[0] = 0x00; address.addr64[1] = 0x13; address.addr64[2] = 0xA2; address.addr64[3] = 0x00; address.addr64[4] = 0x40; address.addr64[5] = 0x08; address.addr64[6] = 0x18; address.addr64[7] = 0x26; if ((ret = xbee_conNew(xbee, &con, "64-bit Data", &address)) != XBEE_ENONE) { xbee_log(xbee, -1, "xbee_conNew() returned: %d (%s)", ret, xbee_errorToStr(ret)); return ret; } if ((ret = xbee_conDataSet(con, xbee, NULL)) != XBEE_ENONE) { xbee_log(xbee, -1, "xbee_conDataSet() returned: %d", ret); return ret; } if ((ret = xbee_conCallbackSet(con, myCB, NULL)) != XBEE_ENONE) { xbee_log(xbee, -1, "xbee_conCallbackSet() returned: %d", ret); return ret; } for (;;) { void *p; if ((ret = xbee_conCallbackGet(con, (xbee_t_conCallback*)&p)) != XBEE_ENONE) { xbee_log(xbee, -1, "xbee_conCallbackGet() returned: %d", ret); return ret; } if (p == NULL) break; usleep(1000000); } if ((ret = xbee_conEnd(con)) != XBEE_ENONE) { xbee_log(xbee, -1, "xbee_conEnd() returned: %d", ret); return ret; } xbee_shutdown(xbee); return 0; }
/* Callback triggered by timer */ int in_xbee_collect(struct flb_config *config, void *in_context) { int ret; void *p = NULL; (void) config; struct flb_in_xbee_config *ctx = in_context; if ((ret = xbee_conCallbackGet(ctx->con, (xbee_t_conCallback*) &p)) != XBEE_ENONE) { flb_debug("xbee_conCallbackGet() returned: %d", ret); return ret; } return 0; }