First-stage implementation hints:

We provide you with a simple application that wires all necessary components but does not implement the full Desync algorithm. This application disregards incoming Desync messages. It uses SysTime.setAlarm() and SysTime.alarmFired() to periodically blink LEDs and report some debug messages.

To implement Desync in the single hop case, you will need to design a state machine that records times of arrivals of desync messages and adjusts its next firing time to be closer to the mean of the arrival times of the previous and next messages. Make sure you read hints in the readmeSysTime file.

The code for the main project can be downloaded (here)

When debugging remember that you can output to a terminal through the debug board. This is done by attaching a mote in the same way as the TOSBase in the warmup project and using iMoteConsole.exe, which is in the same directory as the USBLoaderHost.exe. Output can be generated similiarly to standard C printf statements. As an example

    trace(DBG_USR1,"debug message\n");

would generate the message debug message to appear in the connected iMoteConsole window. Rmember though that you do not have a debug board for every mote, so you have to think about how you want to debug.

This part can start with a relatively simple state machine. In principle you need two states and an alarm. In one state, a mote updates the last time that a message was received before it trigger, then after it triggers and sends out its message, it goes to the other state until it receives the a packet which is the "next" packet. Now you can recompute your firing time anfd return to the the original state. The diagram is shown below.

Remember this is a minimal version which does not handle any corner cases.