Information Technology Reference
In-Depth Information
(message_t* msg, void*payload, uint8_t len) {
}
When a message is received from the transceiver, TinyOS calls this event handler
and provides it with a pointer to the whole message, a pointer to its actual payload,
and information about the message's length.
3.2.1.6
TinyOS: Conclusion
Programming in TinyOS is much simpler and quicker compared to the Full Custom
model of assembly programming, and arguably easier, too. Still, the TinyOS pro-
gramming model has suffered criticism for its still steep learning curve, especially for
programmers accustomed to programming in established languages (such as Java).
3.2.2
Sun SPOTs and the Squawk Virtual Machine
The Squawk virtual machine, created by Sun Microsystems for their Sun SPOT tech-
nology, is one attempt at providing easier-to-use programming model to developers
for sensor networks. Using Sun SPOTs and Squawk, a sensor network developer can
write applications in a slightly modified versionof Java [ 3 ].
Squawk itself is a Java virtual machine running directly on SPOT hardware,
without an underlying operating system. To facilitate execution of such sophisti-
cated software, Sun SPOTs had to be designed with significantly more powerful
hardware, compared to the TinyOS nodes (a Sun SPOT has a 180 MHz 32-bit
processor). This might mean greater energy consumption and less battery life,
compared to TinyOS nodes.
3.2.2.1
Programming Sun SPOTs
As mentioned already, Sun SPOTs are programmed using a variation of Java lan-
guage. SunSPOT applications are MIDlets; the main class of the SunSPOT applica-
tion extends the javax.microedition.midlet.MIDlet class, so constructs typical for
MIDlets, such as startApp(), pauseApp(), and destroyApp(), form the skeleton of a
Sun SPOT application. Therefore, an “entry point” for a Sun SPOT application is
the startApp() method.
The whole functionality of the SPOT is abstracted using the EDemoBoard class.
Typically, a programmer will obtain an instance of this class using EDemoBoard.
getInstance() in the body of the startApp() method. Inputs (sensors and switches)
and outputs (LEDs) are then reachable through Java interfaces, which are obtained
using demoBoardInstance.getxxx () methods. For example, a temperature reading
can be obtained using:
Search WWH ::




Custom Search