<?xml version="1.0" ?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:echo:1</deviceType>
<friendlyName>Echo device</friendlyName>
<manufacturer>Jan Newmarch</manufacturer>
<manufacturerURL>http://jan.newmarch.name</manufacturerURL>
<modelDescription>Jan's Simple Echo Device</modelDescription>
<modelName>Echo</modelName>
<modelNumber>1.0</modelNumber>
<modelURL>http://jan.newmarch.name</modelURL>
<serialNumber>1234567890</serialNumber>
<UDN>uuid:jan_echo_server_1</UDN>
<UPC>123456789012</UPC>
<iconList>
<icon>
<mimetype>image/gif</mimetype>
<width>48</width>
<height>32</height>
<depth>8</depth>
<url>/description/icon.gif</url>
</icon>
</iconList>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:echo:1</serviceType>
<serviceId>urn:schemas-upnp-org:serviceId:echo:1</serviceId>
<SCPDURL>/service_description.xml</SCPDURL>
<controlURL>/service/timer/control</controlURL>
<eventSubURL>/service/timer/eventSub</eventSubURL>
</service>
</serviceList>
<presentationURL>/presentation</presentationURL>
</device>
</root>
<?xml version="1.0"?>
<scpd xmlns="urn:schemas-upnp-org:service-1-0" >
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<actionList>
<action>
<name>Echo</name>
<argumentList>
<argument>
<name>InText</name>
<relatedStateVariable>Text</relatedStateVariable>
<direction>in</direction>
</argument>
<argument>
<name>ReturnText</name>
<relatedStateVariable>Text</relatedStateVariable>
<direction>out</direction>
</argument>
</argumentList>
</action>
</actionList>
<serviceStateTable>
<stateVariable sendEvents="no">
<name>Text</name>
<dataType>string</dataType>
</stateVariable>
</serviceStateTable>
</scpd>
A build.xml is
<project name="UPnP demos" default="usage" basedir=".">
<!-- CONFIGURABLE STUFF HERE -->
<!-- where this directory is -->
<property name="top" value="/home/httpd/html/internetdevices/upnp/java/echo"/>
<property name="upnp_lib" value="${top}/lib/clink132a.jar"/>
<property name="xerces_lib" value="${top}/lib/xercesImpl.jar"/>
<property name="xml_lib" value="${top}/lib/xml-apis.jar"/>
<!-- END CONFIGURABLE STUFF -->
<!-- Directories -->
<!-- Show the usage options to the user -->
<target name="usage" >
<echo message=""/>
<echo message=""/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message="available targets are:"/>
<echo message=""/>
<echo message=" compile"/>
<echo message=" rundevice"/>
<echo message=" runclient"/>
<echo message=" clean"/>
<echo message=" usage"/>
<echo message=""/>
<echo message="See comments inside the build.xml file for more details."/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message=""/>
</target>
<target name="all" depends="init,compile"/>
<!-- CLEAN -->
<target name="clean">
<!-- Delete our the ${build}, and ${deploy} directory trees -->
<delete dir="classes"/>
</target>
<target name="init">
<!-- Create the build directory structure used by compile N deploy -->
</target>
<target name="compile">
<mkdir dir="classes"/>
<javac destdir="classes" srcdir="src"
classpath="${upnp_lib}"
target="1.1"/>
</target>
<target name="runclient" depends="compile">
<java
classpath="${upnp_lib}:${xerces_lib}:${xml_lib}:classes"
classname="controlPoint.Client"/>
</target>
<target name="rundevice" depends="compile">
<exec executable="java">
<env key="CLASSPATH"
path="${upnp_lib}:${xerces_lib}:${xml_lib}:classes"/>
<arg line="device.EchoDevice"/>
</exec>
</target>
</project>
javac
with classpath set to include
src
directory
clink132a.jar
xercesImpl.jar
xml-apis.jar
java
with classpath set to
classes
directory
clink132a.jar
xercesImpl.jar
xml-apis.jar
java device.EchoDevice
java controlPoint.Client
date
which is defined by ISO 8601 by
XML. This represents local time of day using a 24-hour clock as a
string "HH:MM" or "HH:MM:SS". The validity should be boolean
time GetTime();
void SetTime(time);
boolean IsValidTime();
These will depend on state variables Time
and ValidTime
Time
state could change say once a second - this
may be too frequent for network traffic, so choose no. The
ValidTime
will change rarely, and could be important to
other timers, so say yes
<?xml version="1.0"?>
<scpd xmlns="urn:schemas-upnp-org:service-1-0" >
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<actionList>
<action>
<name>SetTime</name>
<argumentList>
<argument>
<name>NewTime</name>
<relatedStateVariable>Time</relatedStateVariable>
<direction>in</direction>
</argument>
</argumentList>
</action>
<action>
<name>GetTime</name>
<argumentList>
<argument>
<name>CurrentTime</name>
<relatedStateVariable>Time</relatedStateVariable>
<direction>out</direction>
</argument>
</argumentList>
</action>
<action>
<name>TimeValid</name>
<argumentList>
<argument>
<name>Valid</name>
<relatedStateVariable>TimeValid</relatedStateVariable>
<direction>out</direction>
</argument>
</argumentList>
</action>
</actionList>
<serviceStateTable>
<stateVariable sendEvents="no">
<name>Time</name>
<dataType>time</dataType>
</stateVariable>
<stateVariable sendEvents="yes">
<name>TimeValid</name>
<dataType>boolean</dataType>
</stateVariable>
</serviceStateTable>
</scpd>
All the source code is available from
here . This includes an ant build.xml
file.
You can use this to build/run the examples by
ant compileclock
ant runtickerclock
ant runcomputerclock
If you don't want to do it this way, you can run any Java compiler/runtime or IDE with
the classpath set to include the files
clink123a.jar
xercesImpl.jar
xml-apis.jar
These files are in the zip file with the source code
A convenience class to handle ISO 8601 time format
Interface for different implementations of timers, matches the methods defined for the timer service
Implementation of timer that gets its time from the computer clock using
the Calendar
class
Another implementation that runs a "ticker" in a thread to update the time. This timer is invalid until something else sets its time
Device
which means it broadcasts information about itself to control points
actionControlReceived()
method - it is an
ActionListener
deviceNotifyReceived()
method - it is a
NotifyListener
This creates a clock device, sets a ticker timer in it and starts the frame
This creates a clock device, sets a computer timer in it and starts the frame
A JFrame
to display the clock
And a JPane
to display the clock