Hi Jude,
That's a basic question on the use of the communication capabilities of
TinyOS and, in my opinion, one of its strengths.
You can start following this tutorial:
http://docs.tinyos.net/tinywiki/index.php/Mote-mote_radio_communication
And you may be interested to have this reference:
http://www.tinyos.net/tinyos-2.x/doc/pdf/tinyos-programming.pdf
In particular the AM_BLINKTORADIO defines a "logical" channel. So every node
transmitting on this channel will be able to reach any other node listening
on this very same channel (if there is rf coverage, of course). Actually,
the same idea mechanism is used to communicate PC with mote via serial port.
For instance, you could have 5 nodes transmitting measurements to a sink in
AM_MEAS, and also you could send them control commands through AM_CONTROL.
This way, from an application level point of view, it is immediate to deal
which each kind of messages, since they will signal different events (one
per each AM_CHANNEL), and that is the reason because you pass it as a
parameter to the AMSenderC, in order to be able to have many different kind
of communications.
Saying in a different way, instead using a switch-case control every time
you get a message, and check the header to know what kind of message it is,
the operating system signals a different event for each kind of message. The
same when transmitting, using this functionality you do not have to set the
kind of channel in a header. It is transparent to the user.
An even more interesting quality of AMSenderC and AM_CHANNELNUMBER is that
it has an associated kind of data. Instead of just filling an array with
the payload you want and having to decode the bytes according with the type
of message, you define a specific struct for each channel. And the name of
that struct is exactly what has to be after the "AM_" constant name. E.g. if
you define "struct controlMsg {} controlMsg;" then you associate this kind
of data to the corresponding channel using "enum {AM_CONTROLMSG 24}".
I hope it clarifies :-)
Cheers!
Sergio
On Sat, Sep 17, 2011 at 4:50 PM, Jude Allister <[email protected]>wrote:
> In the BlinkToRadio example, they use a value AM_BLINKTORADIO = 6, and it's
> passed in to the AMSenderC.
>
> What is it for, and why is it set to 6? What other values can be used?
>
> Also, is there a document somewhere besides the TinyOS.net wiki that
> explains these kinds of things better?
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help