(Updated Nov 15, 2014).
The idea is simple. Xbee 802.15.4 radios cannot communicate off-the-shelf with TinyOS-based moted. They are supposed to, but they do not. Sometimes communication is not possible because of parameter mismatch. In particular, a) TinyOS is set in low power listening mode (not supported in Xbees); or b) Xbees are set up to use the MAXTREAM MAC (not supported by TinyOS); or c) Xbees are set to use 64-bit source addressing (not supported by TinyOS).
Provided all that is avoided, there are still a few things that will prevent communication: the TinyOS Am Type field, and Some Xbee extra bytes. A TinyOS-specific extra field (one byte) in the headers called Am Type allows TinyOS to multiplex the use of the radio among different services executing within the same mote. Because it is not part of the IEEE 802.15.4 standard, Xbees have no support for it. As for the extra bytes, Xbee modules add two extra bytes to the payload in every packet regardless of the payload size. I’m not completely sure of what they are ( I should probably read the Xbee Data sheet again). In either case, the solution is to simply remove the Am Type field and those extra Xbee bytes.
To remove the Am Type field I modified the file CC2420ActiveMessageP.nc, which is in charge of multiplexing messages depending on their AM Type, and then modified CC2420.h where the radio message format is defined. Then removed the two extra bytes from every incoming Xbee packet.
With the new changes, definition of the pre-processor variable XBEE_MODE_ENABLED is required. When XBEE_MODE_ENABLED is defined, it prevents the user (shows compile errors) from using Low Power Listening. It also disables automatically TinyOS Network Layer. So the only thing left for the user to do is: a) Set the Xbee to 16-bit addresing mode, and b) select the 802.15.4 MAC without MAXSTREAM headers.
Example of use
Tested for tmote and TinyOS 2.x (as installed in UbunTOS)
The original files CC2420ActiveMessageP.nc and CC2420.h must be replaced with those provided at the bottom of the page. Both are located in: opt/tinyos-2.x/tos/chips/cc2420/
After replacing the original files, you must define the pre-processor variables XBEE_MODE_ENABLED in your application’s Makefile:
CFLAGS += “-DXBEE_MODE_ENABLED”
Then, as usual:
$ make platform install
The Xbee Module in the following tests is set to 802.15.4 MAC with ACK’s, 16-bit Addressing Mode, and Encryptation Disabled. Setting Hardware Acknowledgements for TinyOS or enabling TinyOS Packet Link Layer makes no difference.
The Demo App (also included in the downloads) echoes back anything that is received from the Xbee, as shown:
Over the years, this “compatible” TinyOS has come in handy, as I’ve used it for a few projects—here they are.
Tested with UbunTOS (follow the link to download).