The first thing an outsider needs to get familiar with is the structure of the program while coding in TinyOS. The official TinyOS tutorial does a great job of making all these basics clear, but I just thought we’d include this post as a token post in order to maintain some sort of order 😛 Feel free to check out the official post and all of their tutorials:
Every-time you start a new project “xyz”, you’ll need at least 4 files.
- xyzC.nc file
- xyzAppC.nc file
- xyz.h file
Laksh has hosted all of our projects on github and I’ll keep referring to the relevant folders so that you could try out the codes as well. For instance we’ve called these skeletal files “null files” and you could have a look at them to understand the basic structure for any TOS project.
A Makefile tells the compiler which flags to set and tells it where your main configuration file is present (xyzAppC.nc). We mainly use the Makefile to also declare the buffer size for the printf commands we use in our projects. One can also set the power level for communication for static range scenarios here.
xyzC.nc file contains your main code where you also declare all the interfaces of the mote (in our case, UC-Berkeley or TelosB or MicaZ) that you’ll be using. xyzAppC.nc is your main configuration file and interfaces your main code with the hardware modules like LEDs, timers, radio module, sensors etc.
The header file is used to declare which channel you’ll be using for communication and also in most of our applications the structure of the message packet that each mote shall be sending. By default, the maximum packet size that one can send is 28 bytes but it can be modified to upto 127 bytes by changing the header file.
That’s it for this post, we’ll keep updating this space with more posts which’ll sort of act as a timeline of the experiments/projects we did till now in this field in the hope that it might be of use to anybody trying to work on similar projects using TinyOS.