Presentation Title
Download
Report
Transcript Presentation Title
Windows CE .net SDK
Miro Juric
Software Design Engineer/Test
Microsoft
Introduction
Overview of UPnP support in Windows CE
(device side)
Overview of UPNP support in Windows CE
(control point side)
IPv6 support
Windows CE support for UPnP Internet
Gateway Device – Demo
Q/A
UPnP support on CE
Device hosting APIs
Control point APIs
Allow implementation of UPnP devices
COM (primary SDK API)
C ( available to OEMs)
Discovery and control of remote devices
COM
Bridging
Expose non-UPnP devices as UPnP
No special support required
UPnP architecture on CE
IUPnPRegistrar
Device hosting
COM layer
IUPnPEventSink
App
Device API
IUpnpDeviceFinder
IUpnpDevice
IUpnpService
Control Point
COM layer
Control Point API
UPNP C API
Device IOCTL
Callback
Eventing
(GENA)
SSDP
WININET
HTTPD
Web
Server
ISAPI extn
Device.exe
UPNP SERVICE
UPnP Device Host
Infrastructure
that simplifies
building UPnP devices and
bridges on Windows®
Allows
hosting of multiple
devices
What does the device host
infrastructure do?
Announces presence of registered devices
Renews the advertisements automatically
Responds to search requests as well
Responds to requests for device/service descriptions
Invokes actions requested by control points on services
Handles eventing
Accepts subscription requests
Maintains the list of subscribers per service
Sends events to all the subscribers
So what does the hosted device
implement?
IUPnPDeviceControl
Is the device manager for contained services and devices
A service object per hosted service. For each service object, implement
the following:
IDispatch
Service exposes a dispatch interface for its exposed actions and
state variables
IUPnPEventSource [Optional]
Service implements this interface to send state variable changes to
the device host infrastructure
Device host infrastructure takes care of everything else!
UPnP device hosting (COM)
Need a XML device description template
Need a SCPD XML file for each service
Implement a COM object exposing
IUPnPDeviceControl
Implement a Dispatch interface for each
service
Call IUPnPRegisterRunningDevice to
publish the device
UPnP Device Hosting (COM)
Device
Description
Template
.xml
Device
Implementation
IUPnPDeviceControl
IUPnPRegistrar
Service 2
Service 1
implementation
Scpd2.xml
Scpd1.xml
IDispatch
IUPnPEventSource
IUPnPEventSink
UPnP
COM
Device
Hosting
Layer
UPnP Device Hosting (COM)
IUPnPDeviceControl is the top level interface to your device
Initialize(
/*[in]*/ BSTR bstrXMLDesc,
/*[in]*/ BSTR bstrDeviceIdentifier, // device to Init (RegisterDevice)
/*[in]*/ BSTR bstrInitString); //identifies the init string specific to device
GetServiceObject(
/*[in]*/
BSTR bstrUDN, // Device UDN
/*[in]*/
BSTR bstrServiceId, // Service ID for which to obtain pointer
/*[out, retval]*/ IDispatch ** ppdispService); //Idispatch pointer to service object
Each service object exposes IDispatch and
IUPnPEventSource
IDispatch is invoked for every control request
IUPnPEventSource is used for outbound event
notifications when a state variable changes
Eventing
To support eventing, a service object implements
IUPnPEventSource
Interface has two methods:
Advise
Device host calls this method and gives the service object a
pointer to an IUPnPEventSink interface
This gives the service object a way to pass back state
changes to device host
Unadvise
Device host calls this method to tear down eventing
To send an event
Service calls IUPnPEventSink::OnStateChanged with a list
of dispids for state variables that have changed
Device host queries the dispids, gets the changed values
and sends an event to the subscribers
Device Registration
Device Host generates the appropriate URLs in the
device description template
Device Host replaces UDNs in the device
description template with globally unique identifiers
Allows the device to be registered on multiple machines
using the same template
Allows the device to be registered on the same machine
multiple times using the same template
Identifier passed back that allows a device to be
unregistered
UPnP Device Hosting (COM)
Use UPnPRegistrar object to publish your
device
RegisterDevice (
/* [in] */ BSTR bstrXMLDesc,
/* [in] */ BSTR bstrProgIDDeviceControlClass,
…
/* [retval][out] */ BSTR *pbstrDeviceIdentifier);
Registers the device to run in context of device host – persists across sys boots
RegisterRunningDevice (
/* [in] */ BSTR bstrXMLDesc,
/* [in] */ IUnknown *punkDeviceControl,
// IUPnPDeviceControl
…
/* [retval][out] */ BSTR *pbstrDeviceIdentifier);
Returns Device identifier to be used for Unregister – does not persist across sys boots
UnregisterDevice(
/* [in] */ BSTR bstrDeviceIdentifier,
/* [in] */ BOOL fPermanent);
GetUniqueDeviceName
Retrieves the UDN of a device
UPnP Device Hosting (C)
Using low level C-style API (OEM only)
In this approach UPnP stack translates UPnP messages for
the UPnP device to calls into a C-style callback function
provided by device implementation. UPnP stack doesn’t
perform any encoding/decoding of arguments or state
variables so device implementation has to deal with values
in the format mandated by UPnP.
Not as full featured, but smaller foot print for OEMs making
very small devices
UPnP Device Hosting (C)
UPnPAddDevice to create a named device
based on your description.
Supply a callback function
UPnPPublishDevice to announce the device
on the network
Callback function invoked on receiving
control requests
UPnPSetControlResponse to send a
response back
UPnPSubmitEvent to send event notifications
to subscribers
Control Point API
COM interfaces for building UPnP control
points
IUPnPDeviceFinder
IUPnPDevices
IUPnPDevice
IUPnPServices
IUPnPService
Object Model
Devices Collection
Device Finder
Device
Services Collection
Object Model
Services Collection
Service
XML (SOAP) to device
Events (GENA) from device
UPnP Control Point
Creating Device Finder
IUPnPDeviceFinder * pDevFind = NULL;
CoCreateInstance(CLSID_UPnPDeviceFinder,
…
IID_IUPnPDeviceFinder,
(void **) &pDevFind);
Search for Device
IUPnPDevices * pFoundDevices = NULL;
bstrTypeURI = SysAllocString
(L”urn:schemas-upnp-org:device:clockdevice”);
pDevFind->FindByType(bstrTypeURI, 0, &pFoundDevices);
::FindByType method searches by device or service type
UPnP Control Point
Enumerate Device
IUPnPDevices *pFoundDevices
IUnknwn *pUnk = NULL;
pFoundDevices->get_NewEnum(&pUnk)
Device Objects in the collection are contained within VARIANT structures
– these structures contain pointers to IDispatch interfaces on the device
objects
// Obtain IUPnPDevice *pDevice interface
Get IUPnPServices – service collection
GetService(IUPnPDevice *pDevice)
IUPnPServices *pServices = NULL;
IUPnPService *pClockServics = NULL;
pDevice->get_Services(&pServices)
UPnP Control Point
Get Service Object
We have IUPnPServices *pServices
IUPnPService *pClockService = NULL;
IUPnPService *pAlarmService = NULL;
bstrClockSvcId = SysAllocString
(L”urn:upnp-org:serviceId:ClockService”)
pServices->get_Item(bstrSvcId, &pClockService)
pServices->get_Item(bstrAlarmSvcID, &pAlarmService)
UPnP Control Point
Invoke Actions – control
IUPnPService::InvokeAction – method
pClockService->InvokeAction
( bstrActionName,
varInArgs,
&varOutArgs,
&varReturnVal);
VARIANT varInArgs;
QueryStateVariable
Discouraged by UPnP Forum
IPv6
Windows CE supports UPnP over IPv4 and
IPv6 networks
IPv6 support only
UPnP devices will use only IPv6 addresses
IPv4 + IPv6
UPnP devices will use IPv6 address with IPv6
capable hosts on the network and IPv4 address
with devices supporting only IPv4
IPv4 only
UPnP devices use IPv4 only - Default
IPv6 Scope
Link Local Addresses (begins with FE80:…..)
This means listening and broadcasting on
FF02::C, the link-local scope multicast address for
the link-local scope multicast address for SSDP –
Default
Site Local Addresses– (begins with FEC0:….)
Link local is used always. Site local is optional in addition
to link local.
Uses scoping of IPv6 addresses to control the propagation
of SSDP messages instead of Hop Limit (equivalent to the
TTL limit in IPv4).
UPnP Samples
Samples in Windows CE .Net
Devices:
Internet Gateway Device
Implements required schema and interacts
with an actual Gateway implementation.
Fully functional IGD – UPnP certified
Control Point:
Universal Control Point sample
Platform Builder 4.10
Platform Builder is an integrated development
environment (IDE) for building customized embedded
platforms based on the Microsoft® Windows® CE
.NET operating system (OS).
Platform Builder comes with all the development
tools necessary for you to design, create, build, test,
and debug a Windows CE–based platform. The IDE
provides a single integrated workspace in which you
can work on both platforms and projects
PB Configurations
Residential_gateway
PDA
Web Pad Enterprise
…
Building Windows CE based
Residential Gateway Image
with UPnP Internet Gateway
Device
Miro Juric
Software Design Engineer/Test
Windows CE
Summary
UPnP supported in Windows CE
Pocket PC – Windowc CE OS
Device hosting included in 4.0
Control point included in 4.0
Same API’s as XP!!
Generic Control Point sample
Working IGD for Gateways
Questions?
For the interconnected lifestyle