Assignment 4 (due Dec. 8 1:30pm)
Motes are designed for data collection and control of the local environment. Therefore, the event-based programming model works well in the setting of wireless sensor networks (WSN), where motes wait and react to events (message arrival, sensor acquisition, and so on). However, this programming model puts the burden of maintaining states across commands and events on the developers. TOSThreads is a thread library for TinyOS that brings back the linear programming model. In this assignment, you will convert an event-driven Sense application like in the previous assignment to a threaded application.
STEP 1: Add TOSThreads support to the routing layer
The assignment views the RoutingTree component as a system service that forwards data packets for the upper-layer application. The current implementation provides the split-phase Send interface. You need to add TOSThreads support by writing the blocking wrapper for the RoutingTree component. The blocking wrapper provides the BlockingSend interface in place of the Send interface provided by the RoutingTree component.
You should first read the TOSThreads tutorial to find out the steps in adding TOSThreads support to new system services. In addition, you will find the blocking wrapper implementation of BlockingStdControl under both tinyos-2.x/tos/lib/tosthreads/system and tinyos-2.x/tos/lib/tosthreads/interfaces directories helpful.
STEP 2: Write the threaded Sense application
TOSThreads tutorial demonstrates how to create and manipulate nesC static threads. You need to change the Sense application to use the TOSThreads nesC API. From a high-level point of view, this involves changes to the following system calls:
- External flash: The TOSThreads wrapper files of the log abstraction (BlockingLogStorageC.nc and BlockingLog.nc) are under tinyos-2.x/tos/lib/tosthreads/system and tinyos-2.x/tos/lib/tosthreads/interfaces directories.
- Onboard SHT11 sensors: The TOSThreads wrapper files of the SHT11 driver (BlockingSensirionSht11C.nc and BlockingRead.nc) are under tinyos-2.x/tos/lib/tosthreads/sensorboards/tmote_onboard and tinyos-2.x/tos/lib/tosthreads/interfaces directories.
- Timer: In most cases, the timer is used to wake up a mote to perform a task. You can use the sleep command provided by the Thread interface to achieve the same behavior.
- RoutingTree: The Sense application now uses the BlockingSend interface provided by the blocking wrapper you wrote in the previous step.
Skeleton code
The code provided for this assignment (available here) is a functional Sense application with the RoutingTree component as the routing layer. The provided code is purely an event-based application. You should first make sure you can run it on the motes. The file also includes an application called FormatFlash, which should be installed first to erase the external flash. When the external flash is successfully erased, the blue LED is turned ON. The command to install the event-based application is
make telosb install,<node_id> bsl,<device_port>
And, the command to install the nesC thread-based application is
make telosb threads install,<node_id> bsl,<device_port>
Note that TOSSIM does not support TOSThreads. LEDs will be one useful debugging tool for providing quick feedback.
Deliverables
- All the code that you have written.
- A README file that describes items that you didn't complete and any thing else that you want me to know.