mkdir -p build/telosIf you see any errors, then there is a problem with your TinyOS setup.
compiling Blink to a telos binary
ncc -o build/telos/main.exe -Os -fnesc-target=msp430 -gcc=msp430-gcc -mmcu=msp430x149 -Wall -Wshadow -DDEF_TOS_AM_GROUP=0x7d -Wnesc-all -target=telos -fnesc-cfile=build/telos/app.c -board= -DIDENT_PROGRAM_NAME="Blink" -DIDENT_PROGRAM_NAME_BYTES="66,108,105,110,107,0" -DIDENT_USER_HASH=0xcd8f8e91L -DIDENT_UNIX_TIME=0x4158b324L -I/home/lair/mdw/src/tinyos/tinyos-1.x/tos/lib/CC2420Radio Blink.nc -lm
compiled Blink to build/telos/main.exe
2338 bytes in ROM
45 bytes in RAM
msp430-objcopy --output-target=ihex build/telos/main.exe build/telos/main.ihex
Windows: make telos install.1 bsl,2In the Windows command above, the last "2" on the line refers to COM3. Use the appropriate number for the COM port that your machine uses for the USB interface.
Linux: make telos install.1 bsl,/dev/ttyUSB0
The red and green LEDs on each corner of the mote should blink, indicating that the node is being reprogrammed. After programming has completed, just the red LED should blink on and off once a second.
Congratulations -- you have successfully programmed a mote!
To learn the ropes of TinyOS program development, your first task is to write a simple program in which the status of each node's light sensor is shown on the LEDs of the other motes. You will be given three motes to Demo with. One of them will be "red", the other "green", and the last"blue". The appropriate color LED should be lit on the mote, as well as the other motes, when the light sensor reading on your "red" is above some threshold value. When the light sensor is below the threshold, the LED should be off on all motes. This is a pretty silly/simple program but requires you to deal with sensors, timing, and radio communication.
There are two light sensors on the Telos mote: A "total solar radiation" (TSR) sensor, and a "photosynthetically active radiation" (PAR) sensor. You are required to use only the TSR sensor. This sensor is fairly sensitive, so you will need to use a fairly low threshold (between 30 and 50) to distinguish between "light" and "dark" in your application.To get started with your program, we suggest you take the code from a simple program (e.g., Blink) and modify it. You must use the same Makefile format as other TinyOS applications. That is, don't try to write a new Makefile "by hand" -- the file must include the lines
COMPONENT=YourAppNamewhere YourAppName is the name of the main component in your application, and MAKERULES has been set previously as part of your Telos installation. You are welcome to develop your program outside of the tinyos-2.x/apps directory, but be sure you include the Makerules file appropriately (and keep in mind that you need to set the MAKERULES environment variable as explained here). The TinyOS make system is pretty sophisticated and we strongly suggest you simply use it this way rather than trying to hack together your own Makefiles.
include $(MAKERULES)
In order to avoid packet collisions with other groups, select your Radio Channel in the Makefile.
NOTE (for your knowledge): Another approach to avoid packet collisions with other groups, is to select an Active Message GroupID in the range 0x10 through 0x50. The GroupID is used to differentiate between radio messages transmitted among "groups" of nodes. To set the GroupID, set the following line at the top of your Makefile, before it includes the Makerules file: DEFAULT_LOCAL_GROUP = 0x40 # For example!!!! The GroupID must be the same on all motes that you are programming in order for them to see each other's packets.
This program is fairly straightforward. The red node should periodically sample their light sensor (every second). If the sensor value is below the threshold, it should turn on its appropriate LED color. Likewise, if the value is above the threshold, it should turn off its LED. In both cases, the node should broadcast a radio message indicating its state to the other node. Upon reception of such a message, a node should turn the appropriate LED (it's designated color) on or off.
A node can identify itself using the macro TOS_LOCAL_ADDRESS which is set when you type
make telos install.1In this case, the mote is being programmed with TOS_LOCAL_ADDRESSset to 1. You can substitute '1' with any other numeric value to give the node a different ID. This allows you to use the same application for all nodes, and just use a case statement to select the mode in use. IE. Use this address to select LED color of the node (e.g., red=1, green=2, etc.) .