Difference between revisions of "Tutorial:ZigBee"
(Version 1.0) |
|||
Line 13: | Line 13: | ||
2) how to burn a program to a TelosB node. | 2) how to burn a program to a TelosB node. | ||
for details you can see [http://tinyos.stanford.edu/tinyos-wiki/index.php/The_simplest_TinyOS_program simplest tinyos program] | |||
---- | |||
1 Configuration file, SimpleAppC.nc | |||
<nowiki> | |||
configuration SimpleAppC{ | |||
} | |||
implementation{ | |||
components SimpleC, MainC; | |||
SimpleC.Boot -> MainC.Boot; | |||
}</nowiki> | |||
this file will link two components <code>SimpleC</code> and <code>MainC</code> | |||
2 SimpleC.nc组件 | |||
<nowiki>module SimpleC{ | |||
uses interface Boot; | |||
} | |||
implementation{ | |||
event void Boot.booted() { | |||
} | |||
}</nowiki> | |||
When system starts, it will call interface booted in <code>MainC</code>, but this interface is not implemented. | |||
So <code>SimpleC</code> implements it. | |||
<code>MainC</code> in nesC is just like main function in C. | |||
In this example, it does nothing, so it just like following code in C: | |||
<nowiki>int main () { | |||
return 0; | |||
}</nowiki> | |||
3 Makefile | |||
<nowiki> | |||
COMPONENT=SimpleAppC | |||
include $(MAKERULES)</nowiki> | |||
with <code>Makefile</code> we can compile the code by typing | |||
<nowiki>make telosb</nowiki> | |||
4 install | |||
To install program to telosb node | |||
<nowiki>make telosb install bsl,/dev/ttyUSB0</nowiki> | |||
===Measurement=== | ===Measurement=== |
Revision as of 16:25, 24 September 2019
This page shows the tutorial for experiments with ZigBee communications and the testbed.
Useful links:
- TinyOS intro (Chinese)
- Programming model of TinyOS (Chinese)
- TinyOS main site and official tutorials
The simplest example
This example shows
1) how the event-driven programming works,
2) how to burn a program to a TelosB node.
for details you can see simplest tinyos program
1 Configuration file, SimpleAppC.nc
configuration SimpleAppC{ } implementation{ components SimpleC, MainC; SimpleC.Boot -> MainC.Boot; }
this file will link two components SimpleC
and MainC
2 SimpleC.nc组件
module SimpleC{ uses interface Boot; } implementation{ event void Boot.booted() { } }
When system starts, it will call interface booted in MainC
, but this interface is not implemented.
So SimpleC
implements it.
MainC
in nesC is just like main function in C.
In this example, it does nothing, so it just like following code in C:
int main () { return 0; }
3 Makefile
COMPONENT=SimpleAppC include $(MAKERULES)
with Makefile
we can compile the code by typing
make telosb
4 install To install program to telosb node
make telosb install bsl,/dev/ttyUSB0
Measurement
To measure various information from received packets.
Code template
Extract info upon receiving a packet.