Sun Microsystems V2.0 manual With adderlib as your current directory, execute the command

Page 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 containing additions to the library

With adderlib as your current directory, execute the command

ant jar-app

to create a jar file containing the library extension. You can check the correct execution of this command by looking in your SDK installation, where you should now find adderlib_rt.jar in the lib directory. The name of the .jar file is controlled from the file build.properties in the root directory of the adderlib directory.

2. Rebuild any of the existing .jar files which you wish to modify

In this example, we don’t plan to modify the supplied library code, and so we skip this step. However, see the section Modifying the system library code for an explanation of what to do if you do wish to make such modifications.

3. Combine the various .jar files into a library suite

Identify the file .sunspot.properties in your user root folder. Add these two lines

spot.library.name=adderlib

spot.library.addin.jars=${sunspot.lib}/adderlib_rt.jar${path.separator}${sunspot.lib}/mul tihoplib_rt.jar${path.separator}${sunspot.lib}/transducerlib_rt.jar

The first line specifies the name of the library suite file, and should replace an existing line that defines the same property. This can be any legal filename you wish (the actual file will be created with a “.suite” suffix).

The second line specifies some of the .jar files will be combined to create a library jar. The three

files listed in .sunspot.properties are

multihoplib_rt.jar (the standard communications stack)

transducerlib_rt.jar (the standard library for the demo sensor board)

adderlib_rt.jar (the sample library extension we’re working with).

In fact, all libraries contain two further .jar files, which do not need to be specified in the

spot.library.addin.jars property:

spotlib_device.jar (core library classes that run on the SPOT device)

spotlib_common.jar (core library classes that run on both the SPOT device and in host applications. For example, the high level interface to radio communication).

Once you have modified .sunspot.properties, execute this command:

ant library

This should create a library suite named adderlib.suite in the arm sub-directory of your SDK installation. Because we have defined the properties that control the “ant library” command in

.sunspot.properties, this command can be executed from any folder that contains a valid

build.xml.

47

Image 47
Contents Page Page Contents Http protocol support Introduction Deploying and running a sample application Building and deploying Sun Spot applicationsBuild Successful Total time 3 seconds \MyApplication Ant -Dport=COM2 info Total time 4 seconds \MyApplication Total time 0 seconds \MyApplication Incorporating utility classes into your application Deploying a pre-existing jarOther user properties Manifest and resourcesExcluding files from the compilation Overview Using the BasestationBuilt-in properties Set up Introduction Base Station configurationRemote operation Connect a Sun Spot base station Background Using short names for SPOTsManaging keys and sharing Sun SPOTs Take suitable actions during over-the-air downloadsSharing Sun SPOTs Changing the owner of a Sun SpotLimitations What is protected?Deploying and running a host application Generating a new key-pairMesh routing Configuring network featuresYour own host application Incorporating pre-existing jars into your host applicationLogging Hardware configurations and USB powerTrace route Page Thread priorities Overview of an applicationThreads Device Interface Sun Spot device librariesSun Spot device library Persistent properties Overriding the Ieee address Accessing flash memoryUsart Radio communication library Program Radiogram protocol Server end Client endYou can open server radiogram connections in a similar way Broadcasting Radio properties Turning the receiver off and on Shallow Sleep Conserving power using deep sleep modeMonitoring radio activity Deep Sleep Activating deep sleep modeDevice Condition to permit deep sleep USB inhibits deep sleepPreconditions for deep sleeping Deep sleep behaviour of the standard driversWriting a device driver Http protocol support Configuring the http protocolSocket Proxy GUI mode Configuring projects in an IDEDebugging Classpath configurationJavadoc/source configuration Ant selectapplication Configuring Eclipse as a debug client Configuring NetBeans as a debug clientAdvanced topics Using library suitesWith adderlib as your current directory, execute the command Use the command Using the spot client SpotSerialPortException other exception in serial port comms Property name Meaning ReferencePersistent system properties Start address Space Use Contents of the arm directoryContents of the lib directory Memory usageContents of the bin directory preverify.exe Contents of the tests directory Contents of the upgrade directory