Transcript 沒有投影片標題
National Chung Cheng University
車機與電信服務整合應用實驗
OSGi-Lab
Chiang, Wei-Kuo (江為國)
Assistant Professor
Department of CSIE
National Chung Cheng University
Office : EA 311
Phone : 05-2720411~33126
Email : [email protected]
URL : http://www.cs.ccu.edu.tw/~wkchiang/
National Chung Cheng University
Dept. Computer Science & Information Engineering
National Chung Cheng University
OSGi Foundation
Lab : OSGi Framework Install
UPnP Foundation
Lab : Use Sip-UPnP Bridging Bundle
Telecom Service Integration for ITS
2
Lab
National Chung Cheng University
OSGi Foundation
Telecom Service Integration for ITS
3
Lab
National Chung Cheng University
Why OSGi?
OSGi Architecture
Benefit
Market
Telecom Service Integration for ITS
4
Lab
National Chung Cheng University
Why OSGi
There should be simpler ways to construct
software systems.
Building systems out of smaller component .
Component that work together.
Managing component
Universal middleware
Telecom Service Integration for ITS
5
Lab
National Chung Cheng University
OSGi Architecture:
The OSGi Service Platform
specifies a layered
architecture for dynamic
component based system
Telecom Service Integration for ITS
6
Lab
National Chung Cheng University
Execution Environment
OSGi APIs only use a subset
of J2SE and J2ME CDC
OSGi Minimum EE
Matches most profiles
Implementations can use
more than the OSGi
Minimum EE
Security is not mandatory
CLDC is possible if class
loaders are added in a device
specific way
Telecom Service Integration for ITS
CLDC/
MIDP
OSGi
Min.
J2SE
CDC/FP
7
Lab
National Chung Cheng University
Module Layer
Packaging of applications and libraries in
Bundles
Raw Java has significant
deployment issues
Class Loading modularization
Raw Java provides the Class Path
as an ordered search list, which
makes it hard to control
multiple applications
bundle
bundle
Protection
Raw Java can not protect certain
packages and classes
bundle
bundle
bundle
Versioning
Raw Java can not handle multiple
versions of the same package
bundle
bundle
Telecom Service Integration for ITS
8
Lab
National Chung Cheng University
Life Cycle Layer
System Bundle represents the
OSGi Framework
Provides an API for managing
bundles
Install
Resolve
Start
Stop
Refresh
Update
Uninstall
System
bundle
Bundle
X-v2
X
Based on the module layer
Telecom Service Integration for ITS
bundle
M
Bundle
A
9
Bundle
B
Lab
National Chung Cheng University
Life Cycle Layer
Bundle is started by the Bundle
Activator class
Header in Manifest refers to this
class
Interface has 2 methods
Start: Initialize and
return immediate
INSTALLED
STARTING
start
Stop: Cleanup
RESOLVED
The Activator gets a Bundle
Context that provides access to
the Framework functions
stop
Framework provides Start Level
service to control the start/stop
of groups of applications
Telecom Service Integration for ITS
ACTIVE
UNINSTALLED
10
STOPPING
Lab
National Chung Cheng University
Service Layer
Provides an in-VM service model
Discover (and get notified about) services based on
their interface or properties
Bind to one or more services by
program control,
default rules, or
deployment configuration
SOA Confusion
Web services bind and discover over the net
The OSGi Service Platform binds and discovers inside a
Java VM
The OSGi Alliance provides many standardized services
Telecom Service Integration for ITS
11
Lab
National Chung Cheng University
Architecture: Framework
Allows applications to share a
single Java VM
Isolation/Security
Communication between
applications
Collaboration between
Applications
Life cycle management
Application
The Application
Application
Application
Application
Blue-Application
Application
Speech
XML
USB
tooth Application
Library
OSGi
OSGi
Web
OSGi
JTAPI
3D
Math
Server
The Application
OSGi
Java
Comm
Java
VM Security
Java
Mail
TCP/IP
Ports
VM
VM
System Class Libraries
Java
Media
DistriJava
Imaging
SQL
VM
Java
FW
buted
VM
Java
VM
VM
CryptoDirecOperating
System GUI
UPnP
Operating
System
graphy
tories
Operating System
Java
Operating System
Java
VM
VM
Policy free
Policies are provided by
bundles and services
API is fully self managed
Operating System
Operating System
Telecom Service Integration for ITS
12
Lab
National Chung Cheng University
Collaborative model
OSGi Framework
Service
registry
Bundle
Bundle
packages
packages
JAVA
Operating System
Hardware
Telecom Service Integration for ITS
13
Lab
National Chung Cheng University
Framework Entities
OSGi Framework
Bundle A
{}
Bundle B
{}
= service, java interface
Bundle C
{}
Telecom Service Integration for ITS
14
Lab
National Chung Cheng University
What is in a Bundle?
A Bundle contains (normally in a JAR file):
Manifest
Code
Resources
The Framework:
Reads the bundle’s manifest
Installs the code and resources
Resolves dependencies
Bundle A
{}
During Runtime:
Calls the Bundle Activator to start the bundle
Manages java classpath
Handles the service dependencies
Calls the Bundle Activator to stop the bundle
Telecom Service Integration for ITS
15
Lab
National Chung Cheng University
Service Specifics
register
A service is an object registered with the Framework by a bundle to be used
by other bundles
The semantics and syntax of a service are specified in a Java interface
A bundle can register a service.
A bundle can use a service (bind to)
1..1
0..1
0..n
A service can be discovered dynamically
Services can go away at any time!
= service, java interface
Telecom Service Integration for ITS
16
Lab
National Chung Cheng University
Services continued
The Framework Service Registry is available to all bundles to
collaborate with other bundles
Different bundles (from different vendors) can implement the same
interface
Implementation is not visible to users
Allows operator to replace implementations without disrupting
service
OSGi defines a standard set of services
Other organizations can define more (AMI-C)
Extensive notifications for services life cycles
Services have a unique id
Services require permission
Under Operator control
Services are associated with properties
Query language to find appropriate service
Bundles can update the properties
Telecom Service Integration for ITS
17
Lab
National Chung Cheng University
Evolution
Mobile
Planned R4
R3
UPnP
Vehicle
Home Automation
Initial Provisioning
Name Space
Jini
Start Level
IO Connector
Wire Admin
XML Parser
Measurement & State
Position
Execution Env.
R2
R1
Application Manager
MIDP Container
Signed Bundles
Declarative Services
Power Management
Device Management
Security Policies
UPnP Exporter
Diagnostics/Monitoring
Framework Layering
Initial Provisioning
UPnP
…
Package Admin
Configuration Admin
Permission Admin
User Admin
Preferences
MetaType
Service Tracker
Framework
Http
Log
Device Access
2000
Telecom Service Integration for ITS
2001
2003
18
2005
Lab
Benefit: Faster Service
Deployment Cycle
National Chung Cheng University
Enables much faster service deployment and
adoption as one does not need to wait for
device to be replace out on the market
Volume deployment can start immediately after
implementation
Various different service distribution models
canbe utilized
Service for small interest groups become
feasible
Telecom Service Integration for ITS
19
Lab
National Chung Cheng University
Benefit: Simplified Software
Development
Requirements can be decomposed, which
simplified software development
Reuse of standard components much less
coupled than objects
Bundles are more self contained which enables
more static testing
Testing is simplified by the service model
Enterprises love the discipline OSGi enforces
Telecom Service Integration for ITS
20
Lab
National Chung Cheng University
What’s in it for you?
Telecom Service Integration for ITS
21
Lab
National Chung Cheng University
Home Automation
Home Automation was the
original use case for the
OSGi Alliance.
An OSGi residential gateway
controls a number of local
networks
An operator aggregates
functions provided by
external parties and
manages them on the
gateway
The residential user is billed
form one point
Telecom Service Integration for ITS
22
Lab
National Chung Cheng University
Vehicles: BMW
Telecom Service Integration for ITS
23
Lab
National Chung Cheng University
Mobiles: Nokia
Telecom Service Integration for ITS
24
Lab
National Chung Cheng University
Pc/Desktop: Eclipse
Eclipse made Pc/Desktop applications possible
written in Java possible because they look as good
as native applications
RCP- Rich Client Platform, based on OSGi
eRCP- Embedded RCP, also based on OSGi
Used by
Lotus same time (IBM, NASA,Adobe, Agence France,
APC, JP Morgan,…)
Telecom Service Integration for ITS
25
Lab
National Chung Cheng University
Industrial
Industrial automation is a
perfect match for OSGi
based platforms
A major X-ray analysis
machine manufacturer bases
their new generation devices
on OSGi
Benefit of better software
process, more flexibility,
remote management
Telecom Service Integration for ITS
26
Lab
National Chung Cheng University
Lab : OSGi Framwork install
Telecom Service Integration for ITS
27
Lab
National Chung Cheng University
安裝Knopflerfish
設定 Eclipse
使用Eclipse 產生OSGi bundle
Telecom Service Integration for ITS
28
Lab
National Chung Cheng University
安裝Knopflerfish(1)
第一步:
下載 OSGi Framework :Knopflerfish
knopflerfish_osgi_2.1.0.jar
官方網站
www.knopflerfish.org
Telecom Service Integration for ITS
29
Lab
National Chung Cheng University
安裝Knopflerfish(2)
第二步
雙擊 knopflerfish_osgi_2.1.0.jar
安裝
Next next next……..
Telecom Service Integration for ITS
30
Lab
National Chung Cheng University
安裝Knopflerfish(3)
第三步:
雙擊 啟動安裝目錄下
knopflerfish.org/osgi/framework.jar
如圖
Telecom Service Integration for ITS
31
Lab
National Chung Cheng University
Telecom Service Integration for ITS
32
Lab
National Chung Cheng University
UPnP Foundation
Telecom Service Integration for ITS
33
Lab
National Chung Cheng University
Contents
Introduction
UPnP entities
UPnP Architecture
Cyberlink UPnP Java SDK
Cyberlink UPnP Tool
Intel Tools for UPnP Technology
Telecom Service Integration for ITS
34
Lab
Introduction
National Chung Cheng University
What is UPnP?
Universal Plug and Play
Objective
Zero-configuration.
Invisible networking
Automatic discovery for a breadth of device
categories.
No device drivers, common protocols are use
instead.
Telecom Service Integration for ITS
35
Lab
Introduction
National Chung Cheng University
Vision
Create a Plug and Play experience for consumers to:
Easily share an Internet connection
Enjoy digital multimedia content on preferred devices
Powerful, Invisible networking!
Complex networking!
Internet
Internet
*
PowerLine
802.11
1394
Bluetooth*
Telecom Service Integration for ITS
36
Lab
Introduction
National Chung Cheng University
Benefits of UPnP
Simple:
•
No device configuration, just Plug and Play
Minimum requirement:
IP based, HTTP
• Small footprint software component on the device.
•
Leverage standards:
HTML,XML,Internet protocols to talk to LAN
• Widely supported networking specification.
•
(MS) Windows XP,ME supports & Multiple UPnP SDK
•
Independent of OS, language, or physical connectivity
Telecom Service Integration for ITS
37
Lab
National Chung Cheng University
UPnP Entities
Three Classes of UPnP Entity
Control Point (CP)
Controlled Device
Bridge
Non-UPnP
Device
Controlled
Device
Control
Point
• User Control Point
• Controlled Device
• Bridge
Telecom Service Integration for ITS
38
Lab
UPnP Entities Point vs.
UPnP Control
Device
National Chung Cheng University
UPnP Device
Root Device
Service
Control Point
Service
UPnP Device
Root Device
Embedded Device
Service
Telecom Service Integration for ITS
39
Service
Lab
National Chung Cheng University
UPnP Architecture
Steps to UPnP Networking
3 Control
4 Eventing
5 Presentation
2 Description
1 Discovery
0 Addressing
0
1
2
3
4
5
Control
Control
Control
Control
Control
Control
point
point
point
point
point
point
and device obtain an address to participate in the network
finds all devices and device advertises its availability
learns about device capabilities
invokes actions on device
listens to state changes of device
controls device and/or views device status using an HTML UI
Telecom Service Integration for ITS
40
Lab
UPnP Architecture
National Chung Cheng University
Step 0 : Addressing
Control point and device get address
Obtain an Address via
Else use Auto IP
Telecom Service Integration for ITS
DHCP server
41
Lab
National Chung Cheng University
Discovery:
Step
1:
Discovery
SSDP (Simple Service Discovery Protocol)
3 Control
4 Eventing
5 Presentation
2 Description
1 Discovery
0 Addressing
Search
Request
Device
Reply
Telecom Service Integration for ITS
42
Lab
National Chung Cheng University
Discovery:
Step
1:
Discovery
SSDP (Simple Service Discovery Protocol)
3 Control
4 Eventing
5 Presentation
2 Description
1 Discovery
0 Addressing
Device
Advertisement
Telecom Service Integration for ITS
43
Lab
National Chung Cheng University
Step 2: Description
3 Control
4 Eventing
5 Presentation
2 Description
1 Discovery
0 Addressing
Device Description
XML Document
Get
Description
Telecom Service Integration for ITS
44
Lab
National Chung Cheng University
Step 2: Description
階層性
Device description、Service description
•
Device
Type
Physical
Logical
container
Service
– Actions
– State variables
container
For
Service Description
each service
Type
URL
for description
URL
for control
URL
for eventing
Expressed in XML
UI
Icons
URL
for presentation
Device Description
Telecom Service Integration for ITS
45
Lab
UPnP Architecture - Device
Description
National Chung Cheng University
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<device>
<friendlyName>short user-friendly title</friendlyName>
<manufacturer>manufacturer name</manufacturer>
<manufacturerURL>URL to manufacturer site</manufacturerURL>
<modelDescription>long user-friendly title</modelDescription>
<modelName>model name</modelName>
<modelNumber>model number</modelNumber>
<modelURL>URL to model site</modelURL>
<serialNumber>manufacturer's serial number</serialNumber>
<UDN>uuid:UUID</UDN>
<UPC>Universal Product Code</UPC>
<URLBase>base URL for all relative URLs</URLBase>
<deviceType>urn:schemas-upnp-org:device:deviceType</deviceType>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:serviceType:v</serviceType>
<serviceId>urn:upnp-org:serviceId:serviceID</serviceId>
<SCPDURL>URL to service description</SCPDURL>
<controlURL>URL for control</controlURL>
<eventSubURL>URL for eventing</eventSubURL>
</service>
Declarations for other services (if any) go here
</serviceList>
<deviceList>Description of embedded devices (if any) go here</deviceList>
<iconList>
<icon>
<mimetype>image/format</mimetype>
<width>horizontal pixels</width>
<height>vertical pixels</height>
<depth>color depth</depth>
<url>URL to icon</url>
</icon>
XML to declare other icons, if any, go here
</iconList>
<presentationURL>URL for presentation</presentationURL>
</device>
<specVersion>
<major>1</major> <minor>0</minor>
</specVersion>
</root>
Telecom Service Integration for ITS
46
Lab
UPnP Architecture - Device
Description
National Chung Cheng University
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<device>
<friendlyName>short user-friendly title</friendlyName>
<manufacturer>manufacturer name</manufacturer>
<manufacturerURL>URL to manufacturer site</manufacturerURL>
<modelDescription>long user-friendly title</modelDescription>
<modelName>model name</modelName>
<modelNumber>model number</modelNumber>
<modelURL>URL to model site</modelURL>
<serialNumber>manufacturer's serial number</serialNumber>
<UDN>uuid:UUID</UDN>
<UPC>Universal Product Code</UPC>
<deviceType>urn:schemas-upnp-org:device:deviceType :v</deviceType>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:serviceType:v</serviceType>
<serviceId>urn:upnp-org:serviceId:serviceID</serviceId>
<SCPDURL>URL to service description</SCPDURL>
<controlURL>URL for control</controlURL>
<eventSubURL>URL for eventing</eventSubURL>
</service>
Declarations for other services (if any) go here
</serviceList>
<deviceList>Description of embedded devices (if any) go here</deviceList>
<iconList>
<icon>
<mimetype>image/format</mimetype>
<width>horizontal pixels</width>
<height>vertical pixels</height>
<depth>color depth</depth>
<url>URL to icon</url>
</icon>
XML to declare other icons, if any, go here
</iconList>
<presentationURL>URL for presentation</presentationURL>
</device>
<specVersion>
<major>1</major> <minor>0</minor>
</specVersion>
</root>
Telecom Service Integration for ITS
urn:domain-name:service:serviceType:v
47
Lab
UPnP Architecture –
Device Description
National Chung Cheng University
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<device>
<URLBase>base URL for all relative URLs</URLBase>
<friendlyName>short user-friendly title</friendlyName>
<manufacturer>manufacturer name</manufacturer>
<manufacturerURL>URL to manufacturer site</manufacturerURL>
<modelDescription>long user-friendly title</modelDescription>
<modelName>model name</modelName>
<modelNumber>model number</modelNumber>
<modelURL>URL to model site</modelURL>
<serialNumber>manufacturer's serial number</serialNumber>
<UDN>uuid:UUID</UDN>
<UPC>Universal Product Code</UPC>
<deviceType>urn:schemas-upnp-org:device:deviceType</deviceType>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:serviceType:v</serviceType>
<serviceId>urn:upnp-org:serviceId:serviceID</serviceId>
<SCPDURL>URL to service description</SCPDURL>
<controlURL>URL for control</controlURL>
<eventSubURL>URL for eventing</eventSubURL>
</service>
Declarations for other services (if any) go here
</serviceList>
<deviceList>Description of embedded devices (if any) go here</deviceList>
<iconList>
<icon>
<mimetype>image/format</mimetype>
<width>horizontal pixels</width>
<height>vertical pixels</height>
<depth>color depth</depth>
<url>URL to icon</url>
</icon>
XML to declare other icons, if any, go here
</iconList>
<presentationURL>URL for presentation</presentationURL>
</device>
<specVersion>
<major>1</major> <minor>0</minor>
</specVersion>
</root>
Telecom Service Integration for ITS
48
Lab
UPnP Architecture –
Service Description
National Chung Cheng University
<?xml version="1.0"?>
<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<actionList>
<action>
<name>actionName</name>
<argumentList>
<argument>
<name>formalParameterName</name>
<direction>in xor out</direction>
<relatedStateVariable>stateVariableName</relatedStateVariable>
</argument>
Declarations for other arguments (if any) go here
</argumentList>
</action>
Declarations for other actions (if any) go here
</actionList>
<serviceStateTable>
<stateVariable sendEvents=“yes” xor “no”>
<name>variableName</name>
<dataType>variable datatype</dataType>
<defaultValue>default value</defaultValue>
<allowedValueRange>
<minimum>minimum value</minimum>
<maximum>maximum value</maximum>
<step>increment value</step>
</allowedValueRange>
</stateVariable>
<stateVariable sendEvents=“yes” xor “no”>
<name>variableName</name>
<dataType>variable data type</dataType>
<defaultValue>default value</defaultValue>
<allowedValueList>
<allowedValue>some value</allowedValue>
<allowedValue>some value</allowedValue>
</allowedValueList>
</stateVariable>
Declarations for other state variables (if any) go here
</serviceStateTable>
<specVersion>
<major>1</major> <minor>0</minor>
</specVersion>
</scpd>
void SetBrightness(int Bright)
Telecom Service Integration for ITS
49
Lab
UPnP Architecture –
Service Description
National Chung Cheng University
<?xml version="1.0"?>
<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<actionList>
<action>
<name>actionName</name>
<argumentList>
<argument>
<name>formalParameterName</name>
<direction>in xor out</direction>
<retval />
<relatedStateVariable>stateVariableName</relatedStateVariable>
</argument>
Declarations for other arguments (if any) go here
</argumentList>
</action>
Declarations for other actions (if any) go here
</actionList>
<serviceStateTable>
<stateVariable sendEvents=“yes” xor “no”>
<name>variableName</name>
<dataType>variable datatype</dataType>
<defaultValue>default value</defaultValue>
<allowedValueRange>
<minimum>minimum value</minimum>
<maximum>maximum value</maximum>
<step>increment value</step>
</allowedValueRange>
</stateVariable>
<stateVariable sendEvents=“yes” xor “no”>
<name>variableName</name>
<dataType>variable data type</dataType>
<defaultValue>default value</defaultValue>
<allowedValueList>
<allowedValue>some value</allowedValue>
<allowedValue>some value</allowedValue>
</allowedValueList>
</stateVariable>
Declarations for other state variables (if any) go here
Bright
</serviceStateTable>
<specVersion>
<major>1</major> <minor>0</minor>
</specVersion>
</scpd>
Telecom Service Integration for ITS
50
Lab
UPnP Architecture –
Service Description
National Chung Cheng University
<?xml version="1.0"?>
<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<actionList>
<action>
<name>actionName</name>
<argumentList>
<argument>
<name>formalParameterName</name>
<direction>in xor out</direction>
<retval />
<relatedStateVariable>stateVariableName</relatedStateVariable>
</argument>
Declarations for other arguments (if any) go here
</argumentList>
</action>
Declarations for other actions (if any) go here
</actionList>
<serviceStateTable>
<stateVariable sendEvents=“yes” xor “no”>
<name>variableName</name>
<dataType>variable datatype</dataType>
<defaultValue>default value</defaultValue>
<allowedValueRange>
<minimum>minimum value</minimum>
<maximum>maximum value</maximum>
<step>increment value</step>
</allowedValueRange>
</stateVariable>
<stateVariable sendEvents=“yes” xor “no”>
<name>variableName</name>
<dataType>variable data type</dataType>
<defaultValue>default value</defaultValue>
<allowedValueList>
<allowedValue>some value</allowedValue>
<allowedValue>some value</allowedValue>
</allowedValueList>
</stateVariable>
Declarations for other state variables (if any) go here
</serviceStateTable>
<specVersion>
<major>1</major> <minor>0</minor>
</specVersion>
</scpd>
Telecom Service Integration for ITS
51
Lab
National Chung Cheng University
Control: SOAP
Step 3: Control
3 Control
4 Eventing
5 Presentation
2 Description
1 Discovery
0 Addressing
Action Result
Stereo
Turns On
Action:
SetPowerOn
Telecom Service Integration for ITS
52
Lab
National Chung Cheng University
Step 3: Control
What is SOAP?
IETF Draft Simple Object Access Protocol
"Lightweight, XML-based protocol for exchange of
information in a decentralized, distributed
environment."
Convention: represent remote procedure calls and
responses.
Telecom Service Integration for ITS
53
Lab
National Chung Cheng University
Step
4:
Eventing
GENA
Eventing: GENA (General Event Notification Architecture)
3 Control
4 Eventing
5 Presentation
2 Description
1 Discovery
0 Addressing
Subscribe
Telecom Service Integration for ITS
54
Lab
National Chung Cheng University
Step
4:
Eventing
GENA
Eventing: GENA (General Event Notification Architecture)
3 Control
4 Eventing
5 Presentation
2 Description
1 Discovery
0 Addressing
Stereo
Turns On
Action:
SetPowerOn
Notify:
PowerOn = True
Telecom Service Integration for ITS
55
Lab
UPnP ArchitecturePresentation: HTML Presentation
National Chung Cheng University
3 Control
4 Eventing
5 Presentation
2 Description
1 Discovery
0 Addressing
HTML UI
Web
Browser
Get
Presentation
Telecom Service Integration for ITS
56
Lab
National Chung Cheng University
UPnP Protocol Stack
Vendor-specific API above
UPnP
UPnPvendor
vendor
UPnP
UPnPForum
Forum
UPnP
UPnPDevice
DeviceArchitecture
Architecture
HTTPU/MU
HTTPU/MU GENA
GENA
SSDP
SSDP
SOAP
SOAP
HTTP
HTTP
UDP
UDP
TCP
TCP
IP
IP
Vendor-specific OS below
Telecom Service Integration for ITS
57
HTTP
HTTP
GENA
GENA
Vendor-specific physical net
UPnP Protocol Stack
Lab
Cyberlink – UPnP Java
SDK
National Chung Cheng University
To use the package, copy the package into your
JDK and JRE library directory. For example:
cp clink170.jar C:/jdk1.x/jre/lib/ext/
cp clink170.jar
C:/ProgramFiles/JavaSoft/JRE/1.x/lib/ext/
The current package needs the following
package to parse the XML and SOAP requests.
CyberLink uses the Xerers package as the
default parser.
Telecom Service Integration for ITS
58
Lab
National Chung Cheng University
Cyberlink UPnP Device
Telecom Service Integration for ITS
59
Lab
National Chung Cheng University
Device Development Step
1.
Write Description file (UPnP standard )
Telecom Service Integration for ITS
60
Lab
National Chung Cheng University
Device Development Step
Extend Class Device Handle Query and Action
2.
•
Implement ActionListener and QueryListener in
your Device
public class ClockDevice extends Device
implements ActionListener, QueryListener
Telecom Service Integration for ITS
61
Lab
National Chung Cheng University
Device Development Step
3.
Initial and start it
Telecom Service Integration for ITS
62
Lab
National Chung Cheng University
Example
public class ClockDevice extends Device
implements ActionListener, QueryListener
{
public ClockDevice()
{
super (“/clock/www/description.xml”);
Action setTimeAction = getAction(“SetTime”);
setTimeAction.setActionListener(this);
Action getTimeAction = getAction(“GetTime”);
getTimeAction.setActionListener(this);
StateVariable stateVar = getStateVariable(“Timer”);
stateVar.setQueryListener(this);
}
Telecom Service Integration for ITS
63
Lab
National Chung Cheng University
public boolean actionControlRecieved(Action action)
{
ArgumentList argList = action.getArgumentList();
String actionName = action.getName();
if (actionName.equals("SetTime") == true) {
Argument inTime = argList.getArgument(“time”);
String timeValue = inTime.getValue();
If (timeValue == null || timeValue.length() <= 0)
return false;
//TODO: do samething
Argument outResult = argList.getArgument(“result”);
arg.setValue(“TRUE”);
return true;
}
else if (actionName.equals(“GetTime”) == true) {
String currTimeStr = …..
Argument currTimeArg = argList.getArgument(“currTime”);
currTimeArg.setValue(currTimeStrs);
return true;
}
action.setStatus(UPnP::INVALID_ACTION, “…..”);
return false;
}
Telecom Service Integration for ITS
64
Lab
National Chung Cheng University
public bool queryControlReceived(StateVariable stateVar)
{
if (varName.equals(“Time”) == true) {
String currTimeStr = ….;
stateVar.setValue(currTimeStr);
return true;
}else{
stateVar.setStatus(UPnP::INVALID_VAR, “…..”);
return false;
}
}
Telecom Service Integration for ITS
65
Lab
National Chung Cheng University
CyberLink UPnP Tool
需要的檔案:
jdk-1_5_0_01-windows-i586-p.exe
Cyberlink.rar
1.請先安裝 jdk
2.解壓縮 Cyberlink.rar
3.將 Cyberlink.rar 內的所有 jar 檔丟進C:\Program
Files\Java\jre1.5.0_02\lib\ext 內
Telecom Service Integration for ITS
66
Lab
National Chung Cheng University
模擬一個 UPnP ControlPoint
叫出一個 command 視窗 ( 執行 cmd )
依解壓縮的位址,切換到以下目錄 D:\Cyberlink\Device
Sample\upnp-controlpoint
輸入 java CtrlPoint
Telecom Service Integration for ITS
67
Lab
National Chung Cheng University
模擬 UPnP Device
同上頁…目錄為 …Device Sample\upnp-light
輸入 java LightFrame
Telecom Service Integration for ITS
68
Lab
National Chung Cheng University
目前有的 device
Telecom Service Integration for ITS
69
Lab
National Chung Cheng University
Intel Tools for UPnP
Telecom Service Integration for ITS
70
Lab
National Chung Cheng University
Lab : SIP UPnP Bridging
Bundle
Telecom Service Integration for ITS
71
Lab
National Chung Cheng University
Architecture
functions
Message flow
DEMO: Test in Remote SIP UA
Telecom Service Integration for ITS
72
Lab
National Chung Cheng University
Architecture
Telecom Service Integration for ITS
73
Lab
National Chung Cheng University
Architecture
Use OSGi framework integrate SIP and UPnP services.
SIP UPnP bridging bundle:
SIP Service bundle:
knopflerfish
UPnP Service bundle:
JAIN SIP protocol stack
UPnP API bundle
Manage local UPnP Device and provide Device management
service to remote Client (SIP UA)
Cyberlink UPnP lib
UPnP Control Point bundle:
Manage local UPnP Device and register it to OSGi
Telecom Service Integration for ITS
74
Lab
National Chung Cheng University
Functions
Provide devices information
Subscribe device state
Like UPnP description
Like UPnP Eventing
Remote Control device
Like UPnP Action and Query
Telecom Service Integration for ITS
75
Lab
National Chung Cheng University
Message flow
1.
Connection
•
•
SUBSCIBE it
NOTIFY Device
information
Telecom Service Integration for ITS
76
Lab
National Chung Cheng University
Message flow
Device Information XML Message
<all_device>
<device>
<friendlyName>short user-friendly title</friendlyName>
<manufacturer>manufacturer name</manufacturer>
<manufacturerURL>URL to manufacturer site</manufacturerURL>
<modelDescription>long user-friendly title</modelDescription>
<modelName>model name</modelName>
<modelNumber>model number</modelNumber>
<modelURL>URL to model site</modelURL>
<serialNumber>manufacturer's serial number</serialNumber>
<UDN>uuid:UUID</UDN>
<UPC>Universal Product Code</UPC>
<deviceType>urn:schemas-upnp-org:device:deviceType :v</deviceType>
…………………………….
</ device >
… .more Device
</all_device>
Telecom Service Integration for ITS
77
Lab
National Chung Cheng University
Message flow
Device Information XML Message
<all_device>
<device>
………………………
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:serviceType:v</serviceType>
<serviceId>urn:upnp-org:serviceId:serviceID</serviceId>
<actionList>
……actions in here
</actionList>
<serviceStateTable>
………service state variable in here
</serviceStateTable>
</service>
...more service
</serviceList>
</ device >
… .more Device
</all_device>
Telecom Service Integration for ITS
78
Lab
National Chung Cheng University
Message flow
Device Information XML Message
<actionList>
<action>
<name>action name<name>
<argumentList>
<argument>
<name>argument name</name>
<derection>in or out</derection>
<relatedStateVariable>stateVariableName</relatedStateVariable>
</argument>
…more argument
</argumentList>
</action>
</actionList>
Telecom Service Integration for ITS
79
Lab
National Chung Cheng University
Message flow
Device Information XML Message
<serviceStateTable>
<stateVariable>
<name>stateVariableName</name>
<dataType>variable dataType</dataType>
<defultValue>default value</defultValue>
<allowedValueList>
<alowedValue></alowedValue>
</allowedValueList>
<allowedValueRange>
<minimum>minimum value</minimum>
<maximum>maximum value</maximum>
<step>increment value</step>
</allowedValueRange>
</stateVariable>
</serviceStateTable>
Telecom Service Integration for ITS
80
Lab
National Chung Cheng University
Message flow
2.
Subscribe device state
•
•
Send a MESSAGE with
UPnP Subscribe
information (XML)
When Device state
change will got a
NOTIFY
(eventDeviceState).
Telecom Service Integration for ITS
81
Lab
National Chung Cheng University
Message flow
Subscribe service XML Message
[Request]
< message>
<controlType> subscribe</controlType>
<deviceUDN>diviceUDN</deviceUDN>
<serviceName>serviceID </serviceName>
< /message>
[Response]
< messageOK>
<controlType> subscribe</controlType>
<response>OK or ERROR</response>
< /messageOK>
Telecom Service Integration for ITS
82
Lab
National Chung Cheng University
Message flow
3.
Remote Control
(Query)
•
•
•
Send Message with
UPnP StateVariable
Query info
SIP UPnP bridging
Query the Device
stareVariable
Got value in 200 OK
Telecom Service Integration for ITS
83
Lab
National Chung Cheng University
Message flow
Device Information XML Message
[Request]
< message>
<controlType> query</controlType>
<deviceUDN>diviceUDN</deviceUDN>
<serviceName>serviceID </serviceName>
<stateVariableName>state Variable name</stateVariableName>
< /message>
[Response]
< messageOK>
<controlType> query</controlType>
<retuen>value</return>
< /messageOK>
National Chung Cheng University
Message flow
4.
Remote Control
(Action)
•
•
•
Send Message with
UPnP Action info
SIP UPnP bridging
control the Device
Got response in 200
OK
National Chung Cheng University
Message flow
Device Information XML Message
[Request]
< message>
<controlType> action</controlType>
<deviceUDN>diviceUDN</deviceUDN>
<actionName>action Name </actionName>
<argumentList>
<argument>
<name>input argument name</name>
<value>input arguement value</value>
</argument>
…more input argument
</argumentList>
< /message>
National Chung Cheng University
[Response]
< messageOK>
<controlType>action</controlType>
<argumentList>
<argument>
<name>output argument name</name>
<value>output arguement value</value>
</argument>
</argumentList>
< /messageOK>
National Chung Cheng University
UPnP-API bundle is in bundle repository
Other bundle is we provide
Telecom Service Integration for ITS
88
Lab
National Chung Cheng University
Start OSGi framework and Install all bundles
Telecom Service Integration for ITS
89
Lab
National Chung Cheng University
Enter the Outbound Proxy IP , user name ,and user password.
Telecom Service Integration for ITS
90
Lab
National Chung Cheng University
DEMO: Test in Remote SIP UA
National Chung Cheng University
Configuration
Telecom Service Integration for ITS
92
Lab
National Chung Cheng University
Registration
Telecom Service Integration for ITS
93
Lab
National Chung Cheng University
Subscibe
Telecom Service Integration for ITS
94
Lab
National Chung Cheng University
National Chung Cheng University
Telecom Service Integration for ITS
96
Lab
National Chung Cheng University
Telecom Service Integration for ITS
97
Lab
National Chung Cheng University
Telecom Service Integration for ITS
98
Lab
National Chung Cheng University
Telecom Service Integration for ITS
99
Lab
National Chung Cheng University
Telecom Service Integration for ITS
100
Lab
National Chung Cheng University
Telecom Service Integration for ITS
101
Lab
National Chung Cheng University
Reference
http://www.osgi.org
www.knopflerfish.org
upnp.org
http://cgupnpjava.sourceforge.net/
http://www.intel.com/
Telecom Service Integration for ITS
102
Lab
National Chung Cheng University
Any Question?
Mobile All-IP Networking Laboratory
Department of Computer Science & Information Engineering