Sunteți pe pagina 1din 5

Simplifying the Development of Sensor Applications

Eric Arseneau, Ron Goldman, John Daniels


Arshan Poursohi, Randall B. Smith Syntropy Ltd
Sun Microsystems Labs 2 Stambourne Way, West Wickham
16 Network Circle Kent BR4 9NF, UK
Menlo Park, CA 94025 jd@syntropy.co.uk
eric.arseneau@sun.com, ron.goldman@sun.com,
arshan.poursohi@sun.com, randall.smith@sun.com

ABSTRACT computer that connects to the world with sensors and actuators.
Despite the large interest in this area, few significant applica-
We report on a project at Sun Microsystems Laboratories invest- tions have been written so far. We believe this is due to the lack
igating small wireless transducer systems. Project Sun™ SPOT, of adequate tools and languages to aid in the prototyping and de-
(Sun Small Programmable Object Technology), provides both velopment of sensor-based applications.
the hardware and software needed to more easily build many
different types of sensor applications. The hardware platform Wireless sensor devices typically have limited capabilities, in
provides enough resources and capabilities to allow developers terms of processing power, amount of memory, and battery life.
to build and experiment with applications without the concern of These limits seem to make it hard for managed runtime lan-
limitations and/or expansion capabilities. The software platform guages, such as the Java TM language, to be considered for these
introduces a full complement of Java™ technologies to wireless types of devices. The perception is that the static and dynamic
transducer systems. It also includes services tailored specifically memory requirements of a managed runtime exceeds those typ-
for these types of systems, such as over-the-air deployment, ically found on these types of devices. Traditionally, wireless
over-the-air debugging, integration with desktop/server systems, sensor applications use languages such as C and assembler to
automatic power management, and more. Combining Java tech- overcome the memory limitations. These languages normally
nologies, standard tool support, custom tools and flexible hard- connect directly to a small embedded operating system (OS).
ware will make working with sensor applications significantly The choice of these languages comes at the expense of a longer
easier. application development time. However, it is widely accepted
that development time using managed runtime languages is less
Categories and Subject Descriptors than that of non-managed languages.
D.2.5 [Software Engineering]: Testing and Debugging—debug- We believe that running Java technology on a wireless sensor
ging aids; D.2.6 [Software Engineering]: Programming Envir- device will simplify application and device driver prototyping,
onments; D.3.4 [Programming Languages]: Processors—inter- thereby increasing the number of developers able to build ap-
preters, run-time environments; D.4.7 [Operating Systems]: plications, as well as their productivity; resulting in more inter-
Organization and Design—real-time systems and embedded sys- esting applications sooner. The Java platform brings with it
tems. garbage collection, pointer safety, exception handling, and a ma-
ture thread library with facilities for thread sleep, yield, and syn-
chronization. Standard Java development and debugging tools
General Terms can be used to write wireless sensor applications. Further, we
Management, Performance, Design, Languages. provide tools for managing, deploying and monitoring these
devices in a graphical user interface called SPOTWorld [2]. This
Keywords paper concentrates on the ways in which development of sensor
applications in such an environment is simplified.
Wireless sensor networks, Sun SPOT, Java programming lan-
guage, energy conservation, modeling. 2. ANATOMY OF A SUN SPOT
At Sun Microsystems Laboratories, we have been investigating
1. INTRODUCTION wireless sensor networks by creating a next generation device
The pervasive computing vision depicts a future in which com- we are calling the Sun™ Small Programmable Object Techno-
putation is widely embedded in the everyday world, like “smart logy, or Sun SPOT [4](see Figure 1). The Sun SPOT main board
dust.” One medium for enabling this vision is the tiny, wireless contains:
• ARM-9 processor
• 512 KB of RAM
• 4 MB of flash memory
Copyright is held by Sun Microsystems, Inc. • Chipcon 2420 IEEE 802.15.4 radio with an on-board
OOPSLA’06, October 22-26, 2006, Portland, Oregon, USA. antenna to give a range of up to 100 meters.
ACM 1-59593-348-4/06/0010.
• supports Isolates, and Isolate migration
• supports standard Java tools
Part of Squawk’s design is to reduce the amount of work a
device needs to do in order to enable it to execute Java code.
Squawk has a desktop component responsible for creating an op-
timized and byte-code-verified binary bundle. This bundle can
then be easily deployed, securely verified, and executed in place
on the device. This is called a split VM architecture. The
desktop component performs work once that would normally
have to be performed every time a Java application is executed.
This split VM features provide significant savings in terms of
Figure 1. Sun SPOT wireless sensor/actuator device, demo execution time and power consumption.
sensor board on top, the main processor and radio in the The fact that Squawk supports standard Java tools provides ap-
middle, and a battery board on the bottom. plication developers the flexibility to use whatever tools they are
Up to two external boards can be attached, stacked on top of comfortable with to write and debug Java applications.
each other. To ease application development we provide a The Squawk VM also supports a feature called Isolates, as de-
“demo” sensor board supplied with an interesting set of capabil- scribed in Java Specification Request JSR 121: Application Isol-
ities: ation API Specification [6]. Squawk’s implementation of Isolates
• 3-axis accelerometer does not completely conform to JSR 121. This API provides a
• light sensor uniform mechanism for managing Java application life cycles
that are isolated from each other, at least with respect to object
• temperature sensor reachability, but that can potentially share underlying imple-
• A/D converter mentation resources. A VM supporting Isolates can run multiple
• 8 tri-color LEDs applications at the same time. Furthermore, each application has
• 5 general purpose I/O pins the illusion that it has its own VM entirely to itself. Having the
ability to execute multiple applications using a single VM,
• 4 high current output pins.
versus using one VM per application, is tremendously beneficial
The various I/O pins make it relatively easy to hook up a wide for a memory constrained device like the Sun SPOT.
range of sensors and actuators without the need to be an expert
Thanks to Isolates, it is possible to manage other applications
at digital hardware (or even know how to solder). For real hard-
from within Java code. These Isolate instances play a key role in
ware designers, the sensor board interface is published and
enabling remote application management on a Sun SPOT by
provides SPI, I2C, and USB interfaces, making it easy to create
SPOTWorld.
custom sensor boards
One extension we have made to JSR 121 is to support Isolate
The device can be fitted with a compact rechargeable battery or
Migration, a feature by which a running Isolate can be halted at
powered via its USB socket, which is also used to recharge the
an arbitrary point in its execution, then streamed to a remote
battery.
device (usually over the radio) to resume execution there. It
Sun SPOT devices are programmed using Java technology, more turns out that there are numerous interesting applications of this
specifically the Connected Limited Device Configuration capability. Sensor networks are (or are anticipated to be) far
(CLDC) of the Java Platform, Micro Edition (Java ME). CLDC more dynamic than conventional networks. For example,
defines a base set of application programming interfaces (API) devices may routinely run low on battery power, and new
and a virtual machine (VM) for resource-constrained devices. devices may be added to a network simply by dropping them
The standard API has been extended to include APIs which are into place. With live application migration, an Isolate could be
specific to Sun SPOT and wireless sensor devices. moved off of a failing device and onto another device for simple
The implementation of CLDC stems from another research pro- in-the-field replacement, and applications could dynamically re-
ject from Sun Microsystems Laboratories, Squawk [1, 5]. distribute themselves should new resources become available.
Squawk is a Java platform primarily written in the Java lan- Isolate migration can serve as a simpler replacement for client-
guage itself and that can be run without the need for an underly- server applications. To collect information from a sensor net-
ing operating system; commonly referred to as running on the work, one would normally write a client program, deploy it to
bare metal. Squawk provides the needed OS services, such as each node, and radio back the required data to a separate server
the handling of interrupts, networking stack, and resource man- that would be responsible for collecting all the data. With Isolate
agement. These services are mostly written in the Java language, migration, one could instead have an application that visits each
as are all device drivers and the 802.15.4 media access control device in turn, collects values to hold within itself, and finally
(MAC) layer. returns “home” to print out or store its data.
A series of features made Squawk ideal for a wireless sensor One could imagine bringing an Isolate in from the field for de-
platform: bugging while the device remains in place, or creating a running
• designed for memory constrained devices deployment of Isolates distributed across simulated devices then
• designed for ease of porting to new platforms moving the Isolates one by one to real Sun SPOTs.
In order to realistically support Isolate migration, we have con- Applications can be deployed from a desktop computer to a Sun
siderable work ahead of us. An application needs hooks so the SPOT either directly, via a USB connection, or over-the-air
VM can warn it of an impending move, and so a newly arrived (OTA) using the 802.15.4 radio. For OTA deployment a second
Isolate can reestablish connections in its new home. We have yet SPOT, connected to the host machine via USB, is used as a bas-
to provide a complete set of these hooks. Also keep in mind estation, giving the desktop machine access to the radio.
that, at the moment, Isolate migration is the migration of the ex- The basestation can also be accessed from user-developed Java
ecution state of an application, it does not include the code of applications running on the host, allowing such applications to
the application. Checks are performed that the code contained transfer data to and from a remote SPOT. One such program is
on a destination device is identical to the code found on the an http proxy that allows remote SPOTs to access the Internet.
device where the Isolate came from. However, none of this work
is really new to the world of object-oriented programming, and One of the key aspects of our use of Squawk, was the ability to
expanding the capabilities of Isolate migration should find even use standard tools, such as debuggers to debug applications dir-
more interesting applications. ectly on device. The Sun SPOT supports the Java Debug Wire
Protocol OTA via a proxy program running on the host machine,
3. THE APPLICATION DEVELOPMENT allowing applications to be debugged on remote devices using
ENVIRONMENT standard Java debug clients, such as those incorporated into
IDEs.
Applications for the Sun SPOT are written on a desktop com- We are developing an integrated management, deployment, de-
puter using standard Java tools, often including an integrated de- bugging, and programming tool called SPOTWorld (see Figure
velopment environment (IDE) such as NetBeans [7]. The Java 2). SPOTWorld can run stand alone, or, as illustrated in the fig-
program is then compiled and packaged into a jar file. ure, can be integrated with an IDE so that code can be written,
Application build and deployment is controlled by platform- compiled, and deployed to a collection of Sun SPOTs with the
independent Ant scripts, which can be integrated with the user’s aid of SPOTWorld.
IDE.

Figure 2. The SPOTWorld environment is shown here running inside the NetBeans IDE. Triangular icons represent applications
running on each device.
In SPOTWorld the user sees each SPOT with its current state in- 5. SECURITY
cluding currently running applications. Users can send com-
mands to the SPOT with context pop-up menus. For example, Security is a very important aspect of sensor applications. To en-
the user can launch an application by selecting from a list of sure that only trusted code is executed, malicious attacks are
those available on the device. The applications themselves can prevented, and secure communications provided, we must
be accessed through a pop-up menu on an icon representing that provide a mechanism for creating trust boundaries between the
application. This enables the user to pause, resume, or exit the host desktops and their owned devices. One also needs to strike
application. In an experimental feature, the user can drag an ap- a balance between usability and security. Allowing for simple
plication from one SPOT to another, thereby causing live applic- sharing of devices without unduly increasing the risks of them
ation migration using the Isolate migration mechanism. being compromised. Ideally, we would want the security mech-
anism to be as transparent as possible to the user.
When running SPOTWorld, each SPOT is represented by a
proxy object that relays messages over the radio to its associated We use public key cryptography which generally allows users to
SPOT. This proxy serves as the “model” in a conventional Mod- communicate securely without having prior access to a shared
el-View-Controller design. Consequently, we can present the secret key. This is done by using a pair of cryptographic keys,
user with multiple views of their SPOTs. In addition to the 2D designated as public key and private key, which are related
layout illustrated in Figure 2, we are adding a tree widget view mathematically. In public key cryptography, the private key is
and plan to develop a 3D view. The tree view represents the de- kept secret, while the public key may be widely distributed. In a
ployed SPOTs as nodes in a conventional list whose elements sense, one key “locks” a lock; while the other is required to un-
can be expanded to show subparts. In the tree view, the top level lock it. More specifically, we use public key digital signatures—
nodes are groups, and the next level presents the individual allowing devices to verify that a message was created with a
SPOTs. The user can access the applications running on the specific private key.
SPOT and inspect the SPOT’s hardware by expanding this node. Our key management proposal (inspired by [3]) offers a unique
combination of the following features:
4. AUTOMATIC POWER MANAGEMENT
• It easily supports large numbers of developers writing and
The need to conserve power is a significant issue for wireless deploying code without access to a global network.
sensor devices. The Sun SPOT has a powerful processor, a radio, • Compromise of a single key only impacts the security of
and lots of memory, and so has the potential to exhaust its bat- code deployment on a small number of devices.
tery within a few hours.
• Key management is completely transparent to the users
A common solution to this problem is to allow an application to for the most common situations.
turn off components it is not using and to elect to enter a special
Each installation of the Sun SPOT software development kit
low-power mode when idle. This places the full burden of man-
(SDK) transparently generates a public/private key pair. Device
aging power consumption on the application developer, who
ownership is established via the installation of an SDK’s public
really wants to concentrate on just the application domain. It is
key. A factory fresh device is configured to have no owner, i.e.
also likely that the application developer will miss opportunities
no public keys installed. The first use of a device, either via a
for power saving, especially during short idle periods.
wired or wireless connection, causes an automatic ownership re-
Instead we have adopted the approach of automating power lationship to be established. Only an owner is allowed to install
management as much as possible. When no thread is scheduled new applications, issue commands, or make ownership changes
to be run for more than a system-specified minimum amount of to a device.
time, the system will automatically enter a power-saving mode.
Any application or command is digitally signed using the SDK’s
If the radio is off then a deep sleep will occur; if the radio is on
private key prior to being sent to a device. In turn a device will
then only a shallow sleep can occur. At present the application
only accept applications or commands that it can successfully
must ensure that it turns off the radio when it is not in use, but
verify against any of its installed public keys.
we will shortly be enhancing the system so that the radio is con-
trolled automatically based on policies set for each open connec- For many environments, such as within a classroom, the policy
tion. governing ownership change can be relaxed. Instead of always
requiring cooperation of the current owner, we can allow owner-
In deep sleep all power is removed from the main ARM9 pro-
ship change if the new owner has physical access to the device.
cessor and the sensor board, leaving just the power controller
This is implemented by having the device overwrite its trusted
chip (a low-power microcontroller that monitors the reset button
key with the newly received key when code is deployed over a
and has a wake-up timer) and the RAM powered. In this mode
direct connection (e.g. a USB cable).
consumption is less than 40 microamps. Starting with a full
charge, the SPOT has sufficient power to remain in deep sleep 6. EXAMPLES
for more than two years.
Sun SPOTs were used as the framework for an installation piece
In shallow sleep all circuits are powered, but the ARM9 halts, at the 2006 ZeroOne Festival in San Jose California [8]. The art
awaiting an interrupt. The SPOT has sufficient power, starting piece used multiple wireless networks to allow interactive parti-
with a full charge, to remain in this mode for approximately one cipation. The experience was designed to provoke thought about
day. public and private spaces and how technology effects them. Sun
SPOTs were used in all aspects of sensing and controlling the
environment. The system used the onboard processing of the
SPOTs to do the routing of messages in a modified peer-based ating custom sensor boards. Third, writing applications in the
system, where the results of the message passing decisions were Java programming language is easier than using lower-level lan-
reflected back to the participants and spectators so that they guages such as C. Programming in the Java language also makes
could see the technology making decisions about the interaction. it possible to share code between applications on the device and
on the desktop, and also makes it easier to integrate the wireless
The Sun SPOT platform eased the development of the installa-
devices with the desktop. Fourth, a program development envir-
tion from start to finish. The first steps were taken using a onment that enables over-the-air deployment and debugging
simple Java SE-based simulation of the proposed grid of lights,
greatly simplifies the task of developing wireless network ap-
then that same Java code was used as the basis for the applica- plications.
tion running on each individual SPOT in the installed artifact.
Once we were running on the real hardware we made use of the The Sun SPOT is a mid-level sensor device that enables explor-
existing transducer libraries to control theater lighting to handle atory programming of sensor applications. The software archi-
lighting effects in hotel rooms, and street light coloring. The tecture is designed to be a framework for experimentation, en-
code was refined and redeployed, using over-the-air deployment couraging the replacement and addition of new components,
to keep from having to physically connect to all of the installed such as a mesh-radio stack.
hardware. The programmers on the project were all Java pro- We hope that the Sun SPOT will make it possible for a variety
grammers, used to working in typical desktop platforms, and of potential developers to experiment with wireless sensor net-
they were able to use the Sun SPOT platform to design and in- works in robotics, art, toys, personal electronics and commercial
stall an embedded system using many low-level hardware con- applications. Java technology on “wireless sensor networks” is
trol protocols, infrared and RF wireless networks in a matter of here now. Program the world!
weeks.
Sun SPOTs were also used by a class at the Art Center College 8. REFERENCES
of Design in Pasadena, California. A class called “The New Eco- [1] Simon, D., Cifuentes, C., Cleal, D., Daniels, J., White, D.
logy of Things” [9] used the Sun SPOT as a platform to develop Java™ on the Bare Metal of Wireless Sensor Devices—The
various ideas forecasting the future of consumer products. The Squawk Virtual Machine. In VEE’06 June 14–16, Ottawa,
class was asked to imagine future uses of embedded computing Ontario, Canada. ACM Press.
and sensing, with the Sun SPOT as an example of what is pos-
sible. The class was able to design simple prototypes of their [2] Smith, R., Cifuentes, C., , and Simon, D. Enabling Java™
imagined products using the built-in sensors and processing of for small wireless devices with Squawk and Spotworld.
the Sun SPOT, giving them the opportunity to flesh out far more OOPSLA Workshop Bringing Software to Pervasive Com-
of their ideas then the usual styrofoam mock up generally does. puting, October 16, 2005.
The interface to their projects used simple extensions of the [3] Stajano F. and Anderson, R. The Resurrecting Duckling:
flash-based programming environment that the students had Security Issues for Adhoc Wireless Networks, In Proceed-
already been trained to use, giving them access to the real world ings of the 7th International Workshop on Security Proto-
in their projects using the same software that they had been us- cols, April 1999, pp 172-194.
ing all along. [4] http://www.sunspotworld.com
7. SUMMARY [5] http://research.sun.com/projects/squawk
We feel that the Sun SPOT platform is ideally suited for the pro- [6] http://jcp.org/en/jsr/detail?id=121
totyping and developing of applications for wireless sensor net- [7] http://www.netbeans.org
works. First, there is enough memory, processing power, etc. on
[8] http://research.sun.com/spotlight/2006/2006-07-28_
each SPOT that one can do interesting things locally; it is much
spot_the_spots.html
easier to prototype when not constrained by tight resources.
Second, it is easy to extend the functionality of a SPOT by con- [9] http://people.artcenter.edu/~vanallen/ecology/
necting sensors or actuators to the demo sensor board or by cre-

S-ar putea să vă placă și