Note: BombillaLight (for 2KB Teloi) does
not support the send function. If you are
using Teloi, then you can either skip to the
Broadcast handler below, or go through this part of
the tutorial with TOSSIM.
Bombilla VMs automatically build and maintain an
ad-hoc routing tree, which for micas uses the
"MintRoute" algorithm implemented in
tinyos-1.x/tos/lib/MintRoute and for Teloi
uses the LQI-based algorithm in
tinyos-1.x/contrib/ucb/tos/lib/MultiHopLQI. In
both, the mote with address zero is the tree
collection point, which forwards packets over the
UART. To build a routing tree, install Bombilla on a
few nodes and plug mote 0 (the base station) into
your serial port. It will take a little while (a
minute or two) for the nodes to discover one another
and build the tree.
A mote can route a buffer to the base station
with a function that takes a buffer as a
parameter. On mica nodes, the function is
send; on Telos RevB nodes it is
sendlqi (Telos RevA nodes do not have
enough RAM to support collection routing in
Maté). Running VMBufferReader as in the
previous lesson will allow you to see the data the
motes route to the base station, which forwards it
to the serial port. Stop Timer0 and Timer1, if they
are running, with a Once handler. Then install this
code as Timer0, and start it with a rate of 1Hz
(setttimer0(10)):
private i;
buffer buf;
bclear(buf);
for i=0 until bfull(buf)
buf[] = light();
next i
send(buf) ! if TelosB, use sendlqi(buf)
This program fills a buffer with light readings
and sends it. Make sure you sensor boards are
attached. You should see output in VMBufferReader
like this:
Received multihop buffer of type PHOTO, size 10 from mote 0
[131][1023][42][939][669][371][716][527][485][443]
Received multihop buffer of type PHOTO, size 10 from mote 1
[218][892][538][260][807][183][632][499][710][93]
The above readings were generated from TOSSIM
with a randomized sensor model: readings from real
motes should be much more uniform.
Once a mote passes a buffer to the ad-hoc routing
subsystem with send, all of the routing
occurs below the VM, in TinyOS code. If you want to
make VMs communicate with one another, you need to
use the Broadcast handler, which the next section
introduces.
|