Page 3 - Contents
3 Contents Introduction .................................................................................................................................... 5 Building and deploying Sun SPOT applications .............................................................................. 6 Deploying and r...
Page 5 - Introduction; Building and deploying Sun SPOT applications; not
5 Introduction The purpose of this guide is to aid developers of applications for Sun SPOTs. The guide is divided into two sections. Building and deploying Sun SPOT applications provides information about how to build, deploy and execute Sun SPOT applications. The topics covered include: • Building ...
Page 6 - Deploying and running a sample application; root directory
6 Building and deploying Sun SPOT applications Deploying and running a sample application The normal process for creating and running an application (assuming you are working from the command line rather than an IDE) is: • Create a directory to hold your application. • Write your Java code. • Use th...
Page 7 - Check communication with your Sun SPOT using the “; ” command, which displays
7 [delete] Deleting directory C:\MyApplication\build [delete] Deleting directory C:\MyApplication\suite [delete] Deleting directory C:\MyApplication\j2meclasses -post-clean: clean: -pre-compile: -do-compile: [mkdir] Created dir: C:\MyApplication\build [javac] Compiling 1 source file to C:\MyApplicat...
Page 9 - notes on the RXTX driver
9 or ant –Dport=COM2 info The difference between these two commands is that the “ spotport ” version will check that there is a Sun SPOT connected to the specified port, whereas the “ port ” version will attempt to connect to a Sun SPOT on the specified port regardless. You should normally use the “...
Page 12 - Deploying a pre-existing jar
12 [java] -------------------------------------------------------------------- [java] Hits - Class:95.74% Monitor:92.38% Exit:100.00% New:98.43% [java] GCs: 2 full, 0 partial [java] ** VM stopped: exit code = 0 ** [java] Exiting [delete] Deleting: C:\SunSPOT\dev\temp\spot-temp-674916937 -post-run: r...
Page 13 - Excluding files from the compilation; Manifest and resources; Other user properties
13 Excluding files from the compilation To exclude files or folders matching a specific pattern from the java compilation, set the ant property spot.javac.exclude.src , either on the command line with –D or in the build.properties file of the project. The value of the property should be specified us...
Page 14 - Manifest and resources.; Using manifest properties to adjust the; Using the Basestation; Overview
14 resources/META-INF/MANIFEST.MF within its root folder. The adderlib extension has such a file, whose content is FavouriteSnake: Viper This defines a property whose value will be available to all applications in a similar fashion to application-specific manifest properties. The addertest applicati...
Page 15 - file in your user root folder:
15 Hos t Sun SPO T (“base s ta tion”) Sun SPO T (“Ta rg e t”) U SB 8 02 .15 .4 radio The Host can be any of the supported platforms (e.g. Windows PC, Mac). The Host application is a J2SE program. The Target application is a Squawk Java program. In the SPOT SDK and documentation the 64-bit addresses ...
Page 16 - Remote operation
16 Base Station configuration It is possible to select a channel and pan id for the base station using command line properties in conjunction with ant host-run . The properties are: -Dremote.channel=nn -Dremote.pan.id=nn Alternatively, if you are operating in dedicated mode, the IRadioPolicyManager ...
Page 17 - Connect a Sun SPOT base station
17 To configure the SPOT so that this thread is started each time the SPOT starts issue this command via a USB connection: ant enableota The SPOT remembers this setting in its configuration area in flash memory. To configure the SPOT so that the OTA Command Server is not started each time the SPOT s...
Page 18 - Managing keys and sharing Sun SPOTs; Background
18 remote.pan.id either on the command line or in the .sunspot.properties file in your user root folder. Using short names for SPOTs As a shortcut, it is possible to use short names for SPOTs instead of the full 16-digit IEEE address. To do this create a file called “spot.names” in your user home di...
Page 19 - and before user B has executed; Sharing Sun SPOTs; sub-directory of the “master” user’s
19 Even if you aren’t concerned about security, you need to be aware of this if you want to be able to use Sun SPOTs interchangeably amongst two or more SDK installations. See the section Sharing Sun SPOTs . Changing the owner of a Sun SPOT Once set, only the owner can change the public key remotely...
Page 20 - Generating a new key-pair; Limitations; Deploying and running a host application; Example; contains a simple host; ”, or within your host
20 ant deploy for each Sun SPOT. What is protected? Applications and customized libraries are always verified and unless the digital signature can be successfully verified using the trusted public key, the application will not be executed. Extra security is provided for over-the-air deployment. In t...
Page 21 - Configuring network features; Mesh routing
21 When the switch is specified a basestation will still be correctly identified if one is available, but if no basestation is available the port property will be set to dummyport. Your own host application You should base your host application on the template provided. Your host application can ope...
Page 22 - command) it will begin; Hardware configurations and USB power; SPOT only
22 For situation 2 above you should configure the SPOT as a dedicated mesh router, using the command: ant selectmeshrouter When the SPOT is reset (by pressing the attention button or by an ant run command) it will begin acting as a dedicated router. A SPOT set in this configuration does not need the...
Page 24 - Overview of an application; Threads
24 Developing and debugging Sun SPOT applications Overview of an application A Sun SPOT application is actually implemented as a MIDlet. This should not concern most developers greatly: the simplest thing is to copy a template, as described above, and start editing the copy. The most significant imp...
Page 25 - The Sun SPOT device libraries; Device
25 The libraries only use system priorities in three cases: 1. To guarantee that application threads don't run during a system operation during which the system may be in an inconsistent state. 2. To guarantee short uninterruptible periods of operation for critical hardware interaction. 3. To ensure...
Page 26 - Therefore you should normally use
26 Each physical device is controlled by a single instance of the respective class, accessed through the interfaces listed above. The single instance of the Sun SPOT class creates and manages access to the device driver singletons. The singletons are created only as required. For example, to get acc...
Page 27 - Overriding the IEEE address
27 - there is a possibility that another isolate has written a new value for the property since the current isolate started - your application has overwritten the user-defined property’s value in memory but not in flash (by executing System.setProperty ). All user-defined properties can be accessed ...
Page 28 - Using input and output streams over the USB and USART connections
28 example above two sectors are allocated (and thus erased), starting with the first sector available to applications. Using the Record Management Store The Record Management Store (RMS) that is part of the Java IM Profile provides a simple record-based mechanism for access to persistent data. Here...
Page 29 - The radio communication library
29 Configuring USART parameters The URL for USART access can uniquely be extended with additional parameters to configure the USART if required. For example: InputStream inputStream = Connector.openInputStream( "serial://usart?baudrate=57600&databits=7&parity=even&stopbits=1.5");...
Page 30 - Radio properties; Program 1
30 The radiogram protocol provides datagram-based communication between two devices. This protocol provides no guarantees about delivery or ordering. Datagrams sent over more than one hop could be silently lost, be delivered more than once, and be delivered out of sequence. Datagrams sent over a sin...
Page 31 - Program 2
31 Program 2 RadiostreamConnection conn = (RadiostreamConnection) Connector.open("radio://0014.4F01.0000.0007:100"); DataInputStream dis = conn.openDataInputStream(); DataOutputStream dos = conn.openDataOutputStream(); try { String question = dis.readUTF(); if (question.equals("Hello up ...
Page 32 - Client end
32 where serverAddr is the 64bit IEEE Address of the radio of the server, and portNo is a port number in the range 0 to 255 that identifies this particular connection. Note that 0 is not a valid IEEE address in this implementation. The port number must match the port number used by the server. Data ...
Page 33 - There are some points to note about using datagrams:; The; and; classes provide a method for setting a
33 There are some points to note about using datagrams: • Only datagrams obtained from the connection may be passed in send or receive calls on the connection. You cannot obtain a datagram from one connection and use it with another. • A connection opened with a specific address can only be used to ...
Page 34 - As described in the section
34 There are some important points to note about using this operation: • If setting a timeout it must be set before opening streams or creating datagrams. • A TimeoutException is generated if the caller is blocked waiting for input for longer than the period specified. • Setting a timeout of 0 cause...
Page 37 - Monitoring radio activity; Conserving power using deep sleep mode; Shallow Sleep
37 RSSI (received signal strength indicator) measures the strength (power) of the signal for the packet. It ranges from +60 (strong) to -60 (weak). To convert it to decibels relative to 1 mW (= 0 dBm) subtract 45 from it, e.g. for an RSSI of -20 the RF input power is approximately -65 dBm. CORR meas...
Page 39 - Preconditions for deep sleeping; Deep sleep behaviour of the standard drivers; The deep sleep/wake up sequence
39 If it is important that your application knows whether or not deep sleep happened, then you can alternatively execute this code: ISleepManager sleepManager = Spot.getInstance().getSleepManager(); SleepManager.ensureDeepSleep(5000); This code will either deep sleep for the specified time of 5,000 ...
Page 40 - Writing a device driver
40 2. Of all threads executing a Thread.sleep() it determines which will resume soonest. If the sleep interval is less than the minimum deep sleep time it shallow sleeps. 3. If the sleep interval is at least the minimum deep sleep time and deep sleeping is enabled, it sends a request to the SleepMan...
Page 41 - host
41 http protocol support The http protocol is implemented to allow remote SPOT applications to open http connections to any web service accessible from a correctly configured host computer. To open a connection do: HttpConnection connection = (HttpConnection)Connector.open("http:// host :[ port]...
Page 42 - Socket Proxy GUI mode; Radio port usage; Configuring projects in an IDE
42 HTTP Proxy If the host computer running the Socket Proxy is behind a proxy server, the device can still access the Internet if the following property is specified in the MANIFEST.MF: com.sun.squawk.io.j2me.http.Protocol-HttpProxy: <proxyaddress>:<port> where proxyaddress is the hostna...
Page 43 - Debugging; Squawk Debug Agent; In the root directory of your application do
43 Classpath configuration The classpath for an application that runs on a Sun SPOT needs to include the following jars in this order: SDK_INSTALL_DIRECTORY/lib/transducerlib_rt.jar SDK_INSTALL_DIRECTORY/lib/multihoplib_rt.jar SDK_INSTALL_DIRECTORY/lib/spotlib_device.jar SDK_INSTALL_DIRECTORY/lib/sp...
Page 45 - Using manifest properties to adjust the radio; Configuring NetBeans as a debug client; Unexpected; Configuring Eclipse as a debug client; Unexpected
45 Using non-default channel or pan id It is not possible for an application being debugged to select dynamically a different channel or pan id. Instead the required channel or pan id must be selected using manifest properties (see section Using manifest properties to adjust the radio ). Then the re...
Page 46 - Advanced topics; Using library suites
46 Expand each of the first four of these, then select and edit the “Source attachment”. Point this to the relevant source jar as follows: transducerlib_rt.jar SDK_INSTALL_DIRECTORY/src/transducerlib_source.jar multihoplib_rt.jar SDK_INSTALL_DIRECTORY/src/multihoplib_source.jar spotlib_common.jar SD...
Page 47 - Modifying the system library code
47 Start by copying LibraryExtensionSampleCode to a working area. This contains two sub-directories: adderlib and addertest . adderlib contains the library. You should find a sub-directory containing the library Java source: you can add to or edit this as you see fit. 1. Build any new .jar files con...
Page 49 - Using the spot client
49 The source code for the libraries is supplied in three parts: spotlib_source.jar contains the code that supports the SPOT main board; multihop_source.jar contains the radio communications stack; and transducerlib_source.jar contains the code that supports the Demo Sensor Board. This example shows...
Page 51 - Reference; Persistent system properties; Property name
51 Reference Persistent system properties Property name Meaning spot.hardware.rev spot.powercontroller.firmware.version spot.sdk.version spot.external.0.part.id spot.external.0.hardware.rev spot.external.0.firmware.version spot.external.1.part.id spot.external.1.hardware.rev spot.external.1.firmware...
Page 52 - Memory usage; Start address; SDK files; Contents of the arm directory:
52 Memory usage The Sun SPOT flash memory runs from 0x10000000 to 0x10400000 (4M bytes), and is organized as 8 x 8Kb followed by 62 x 64Kb followed by 8 x 8Kb sectors. The flash memory is allocated as follows: Start address Space Use 0x10000000 64Kb Bootloader 0x10010000 256Kb VM executable 0x100500...
Page 53 - ant debug; Contents of the bin directory:
53 debugger_classes.jar The classes of the Sun SPOT high-level debugger. Used by the debug proxy. desktop_signing.jar Classes that are used to security sign suites and commands. j2se_classes.jar The J2SE classes used by Squawk on the desktop. Used by the debug proxy. junit.jar The well-know Java tes...