Skip to content

Instantly share code, notes, and snippets.

@eatnumber1
Created November 25, 2011 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eatnumber1/1392623 to your computer and use it in GitHub Desktop.
Save eatnumber1/1392623 to your computer and use it in GitHub Desktop.
uint64_t zigbees[3]; // This somehow gets initialized (list of zigbee IDs)
int xbfd;
xbapi_op op_structs[3];
xbfd = xbapi_init("path to fd");
for (int i = 0; i < 3; i++) {
xbapi_initi_op(op_structs[i]);
xbapi_transmit(op_structs[i], "Hello Zigbee", zigbees[i]); // Should return error codes
}
// select/poll/epoll on xbfd
// if readable
xbapi_result ret = xbapi_process_data(xbfd, op_structs); // Uses malloc internally to build structs
for (xbapi_op *op = ret.completed_ops; op != NULL; op++) {
// Use op->result to do something
}
for (xbapi_msg *message = ret.messages; message != NULL; message++) {
printf("Got a message (%s) from %s\n", message->data, message->origin);
}
xbapi_free_result(ret);
// endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment