A few days ago I posted about libavrxbee, a library for working with Digi XBee radio modules with the AVR line of microcontrollers. Since then, the first bit of code has been committed and is available for use. I thought it would be nice to give a quick introduction on using the library.
The below code creates an XBee Transmit Request API frame, which can then be sent to an XBee module through UART.
struct xbee_tx_request r; r.addr = 0x0013A20040694E65; r.data = (unsigned char*)strdup("coming from the atmega328P!"); r.len = strlen("coming from the atmega328P!"); struct xbee_frame *f; f = xbee_create_tx_request_frame(0x01, &r); free(r.data); unsigned int size; unsigned char *bytes; bytes = xbee_frame_to_bytes(f, &size); free(f); usart_tx_blob(bytes, size); free(bytes);
This gives you an idea of how easy it is to work with, as well as the overall design which future functionality will be based on. As you can see it's dead simple.
A bit more information on the library:
using it consists of just copying the xbee.c and xbee.h files to your project or including them from libavrxbee
alternatively you can copy the required functions and structures and incorporate them directly into your code
designed for and only tested with XBee Series 2 modules. If anyone wants to contribute code to support other XBee modules, pull requests are welcome.
it isn't necessarily limited to AVR. The library can be used with any architecture. If used with big-endian, only a few minor code changes would be needed.
If you're interested in contributing, send a pull request. Otherwise, you can follow the github repository for updates.