View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

jstK framework

This page contains instructions on implementing your mediator with the XML control channel. Source code and example implementations can be found in
jstk.jar
To create your own device mediator, you will need to:

Mediator-side:

1) Include the following packages into your project/classpath:
xercesImpl.jar
xmlParserAPIs.jar

2) Create a class that extends jstk.mediator.AbstractMediator.
An example implementation is jstk.tinyos.TinyOSMediator.

3) Create a XML ContentHandler class that extends org.xml.sax.helpers.DefaultHandler.
An example implementation is jstk.tinyos.TinyOSXMLHandler.

4) When implementing the getConnector() method required by AbstractMediator, be sure to create the XMLSocketSource using your version of XML ContentHandler.

5) Modify jstk.mediator.MediatorFactory so that it would return an instance of your Mediator based on the input parameters.

Client-side (mediator proxy):

1) Create a MediatorProxy class based on your Mediator.
An example implementation is jstk.tinyos.TinyOSMediatorProxy.

2) Create a client XML ContentHandler similar to the one for the mediator.
An example implementation is jstk.tinyos.ClientXMLHandler.

3) Be sure that xmlParserAPIs.jar and xercesImpl.jar are included in your classpath.


Notes:

1) jstk.tinyos package contains an example mediator and mediator proxy implementation of the
berkeley motes, which runs on the TinyOS platform. These classes require the tinyos API
and devices to work properly.

2) The XML ContentHandler of the mediator proxy and the mediator defines how the XML documents
are parsed. the handlers' endElement() method will invoke functions defined in the proxy/mediator.

The XML messages used for TinyOSMediator are in the following format. You may define your own tags,
as long as they are parsed by your ContentHandler.

TinyOS XML messages:

commands (from mediator proxy to mediator):

Example 1:
<jstk>
<commands>
<query>select light</query>
</commands>
</jstk>


Example 2:
<jstk>
<commands>
<abortQuery></abortQuery>
</commands>
</jstk>


results (from mediator to the mediator proxy):

Example 1:
<jstk>
<results>
<tuple>
<qid>2</qid>
<epoch>23</epoch>
<light>345</light>
</tuple>
</results>
</jstk>


Example 2:
<jstk>
<results>
<aggregate>
</aggregateValue>
<qid>3</qid>
<epoch>24</epoch>
<group>1</group>
<value>456</value>
</aggregateValue>
</results>
</jstk>


Example 3:
<jstk>
<results>
<confirm>command processed</confirm>
</results>
</jstk>


Example 4:
<jstk>
<results>
<failure>command failed</failure>
</results>
</jstk>


Links to this Page