Embedded Networks

MCUs, sensors, prototyping, drivers, etc


Trickle Algorithm Demo


Posted By on Nov 15, 2012

Co-author of this demo: Curtis L. Page (UNBC Computer Science)

 

Trickle is a very simple data propagation algorithm for wireless lossy networks.  See PDF presentation here (intended to be watched in full screen)

 

 

Working demo

 

Read More

(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

 

If for some reason you try to enable low power listening you will get the following message:

 

 

Demos

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:

xbee tinyos test_

 

 

 

 

 

 

 

Over the years, this “compatible” TinyOS has come in handy, as I’ve used it for a few projects—here they are.

 

 

 

Download

Tested with UbunTOS (follow the link to download).

Download

 

Read More

 

In Serial.h serial packets datatype is defined as:

typedef nx_struct serial_packet {
     serial_header_t header; //Headers!
     nx_uint8_t data[];
} serial_packet_t;

but, what if we don’t want to send any headers, i.e. raw data ???

 

Solution

A TinyOS interface that allows an application to tell the Serial Dispatcher, which is in charge of packet formatting, whether to use headers or not in the serial packets.


interface SerialConfigure {
  command void useHeaders( bool use_headers );
}

 

This is where the Serial Dispatcher is in TinyOS’s serial stack:

 

 

TinyOS Serial stack. Taken from TinyOS Documentation

The actual implementation is in SerialDispatcherP.nc, thus the original file must be replaced with the one provided at the bottom of this page. Then apps only need to implement the SerialConfigure interface.

 

 

 

Example of Use
( Not relevant code is omitted. See complete code on download area )

configuration TestAppC{
}
implementation{
    components TestC as App;
    App.UartConfigure -> SerialDispatcherC.SerialConfigure; //we must wire it to the Serial Dispatcher,
}

module TestC{
    uses interface SerialConfigure as UartConfigure; 
}
implementation{
    event void Boot.booted(){
        call UartConfigure.useHeaders(FALSE); //Then we set to false or true 
    }
}

 

Results

When calling UartConfigure.useHeaders( TRUE )

When calling UARTConfigure.useHeaders( FALSE )

 

Downloads

 

Download Read More