Document 13124245

advertisement
TDDI07 Distributed embedded software and networks Department of Computer and Information Science Lab 2 – Wireless communication
Learning objectives
The main objective of this lab is to make the student familiar with the wireless
communication using sensor nodes.
Specifically, after completing the lab the student shall be able to:
•
•
Explain which are the interfaces and components provided by TinyOS to
send packets.
Program an application that uses the wireless communication capabilities
of real sensor nodes.
Assignment: Traffic light
You will implement the following scenario on two motes. During work on a road
mobile traffic lights are set to direct the traffic:
Each light has two states, one active and one passive. In the active state the light
will cycle from red to yellow to green and then back yellow to finally stop at red.
At this point it will signal the other light, which will become active, and then go to
the passive state until it receives a signal from the other light.
You will simulate the lights using the leds on two motes. Use radio
communication to synchronize the lights so one light is always active while the
other is passive (in the passive state the light is always red). The table below
outlines the behaviour and the delays you will use. The active mote has to signal
the other one before becoming passive.
Light
Red
Yellow
Green
Yellow
Red
Time (seconds)
3
0.5
3
0.5
-
State
Active
Active
Active
Active
Passive
Debug message
Why is it always red?
Finally changing!
Go go go! It's green!
You should stop…
Waiting for signal
Basic application:
You are given a basic application that sends messages from a mote to another.
You are required to study the code and wire the components with the interfaces
in order to make it work. You may want to have a look to the additional
resources.
The application works as follows: one of the motes sends a message every 2
seconds with its group number and node ID. The receiver writes a line using
printf and toggles the led at every packet reception. The structure of the message
is defined in the file TrafficLight.h.
TDDI07 Distributed embedded software and networks Department of Computer and Information Science Before you run the application, the following parameters have to be changed:
•
•
•
Group number (in TrafficLight.h)
Channel: 802.11.15 has 26 channels. You have to select the one
corresponding to your group and change it in the makefile.
Node ID: the node ID can be specified at the time of installing the
application in the mote.
Run the application and verify that it works.
Finite state machine:
Once you have understood the basic application and how to use the
communication capabilities, you are required to implement a finite state machine
that performs the actions of the table shown above. The signal will be sent only
to the node in your group and not in broadcast. Make sure that you only change
from passive to active state when receiving the signal from your own motes.
To hand in:
Once the lab is finished, the student has to show the application running in the
sensor nodes to the lab assistant.
After showing the application, the student must send a zip file containing a
written report answering correctly to the lab preparatory questions and the final
source code of the applications. You also have to explain in brief how your
application works.
The e-mail must contain the string “TDDI07 Lab X Group Y” where X is the lab
number in the subject name and Y is the group number.
Additional resources for this lab:
TinyOS programming:
http://www.tinyos.net/tinyos-2.x/doc/pdf/tinyos-programming.pdf
TinyOS tutorials:
http://docs.tinyos.net/tinywiki/index.php/TinyOS_Tutorials
Mote-to-mote communication:
http://docs.tinyos.net/tinywiki/index.php/Mote-mote_radio_communication
Download