windows ce.net sdk miro juric software design engineer/test microsoft

31
Windows CE .net SDK Miro Juric Software Design Engineer/Test Microsoft

Upload: serenity-mores

Post on 01-Apr-2015

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

Windows CE .net SDK

Miro Juric

Software Design Engineer/Test

Microsoft

Page 2: 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

Page 3: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

UPnP support on CE Device hosting APIs

Allow implementation of UPnP devices COM (primary SDK API)

C ( available to OEMs)

Control point APIs Discovery and control of remote devices COM

Bridging Expose non-UPnP devices as UPnP No special support required

Page 4: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

UPnP architecture on CE

Device

.exe

UPNP SERVICE

HTTPDWeb

Server

WIN

INET

Eventing(GENA)

SSDP

UPNP C API

Device hostingCOM layer

Control PointCOM layer

ISA

PI e

xtn

Ap

p

Device IOCTL Callback

Device API Control Point API

IUpnpDeviceFinder

IUpnpDevice

IUpnpService

IUPnPRegistrar

IUPnPEventSink

Page 5: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

UPnP Device Host

Infrastructure that simplifies building UPnP devices and bridges on Windows®

Allows hosting of multiple devices

Page 6: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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

Page 7: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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 Service exposes a dispatch interface for its exposed actions and state variablesstate variables

IUPnPEventSource [Optional] Service implements this interface to send state variable changes to Service implements this interface to send state variable changes to

the device host infrastructurethe device host infrastructure

Device host infrastructure takes care of everything else!

Page 8: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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

Page 9: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

Device Implementation

Service 2

UPnP Device Hosting (COM)

Service 1implementation

IUPnPDeviceControl

IDispatch

DeviceDescriptionTemplate

.xml

Scpd2.xmlScpd1.xml

UPnPCOM

DeviceHostingLayer

IUPnPRegistrar

IUPnPEventSink

IUPnPEventSource

Page 10: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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

Page 11: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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 Device host calls this method and gives the service object a

pointer to an IUPnPEventSink interfacepointer to an IUPnPEventSink interface This gives the service object a way to pass back state This gives the service object a way to pass back state

changes to device hostchanges to device host Unadvise

Device host calls this method to tear down eventingDevice 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

Page 12: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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

Page 13: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

UPnP Device Hosting (COM)

Use UPnPRegistrar object to publish your device

RegisterDevice (

/* [in] */ BSTR bstrXMLDesc,/* [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] */ 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 deviceRetrieves the UDN of a device

Page 14: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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

Page 15: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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

Page 16: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

Control Point API

COM interfaces for building UPnP control points IUPnPDeviceFinder IUPnPDevices IUPnPDevice IUPnPServices IUPnPService

Page 17: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

Device FinderDevices Collection

Device

Services Collection

Object Model

Page 18: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

Services Collection

Service XML (SOAP) to device

Events (GENA) from device

Object Model

Page 19: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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

Page 20: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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)

Page 21: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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)

Page 22: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

UPnP Control Point

Invoke Actions – control IUPnPService::InvokeAction – method pClockService->InvokeAction

( bstrActionName,

varInArgs,

&varOutArgs,

&varReturnVal); VARIANT varInArgs;

QueryStateVariable Discouraged by UPnP Forum

Page 23: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

IPv6

Windows CE supports UPnP over IPv4 and IPv6 networks IPv6 support only

UPnP devices will use only IPv6 addressesUPnP devices will use only IPv6 addresses IPv4 + IPv6

UPnP devices will use IPv6 address with IPv6 UPnP devices will use IPv6 address with IPv6 capable hosts on the network and IPv4 address capable hosts on the network and IPv4 address with devices supporting only IPv4with devices supporting only IPv4

IPv4 only UPnP devices use IPv4 only - DefaultUPnP devices use IPv4 only - Default

Page 24: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

IPv6 Scope

Link Local  Addresses (begins with FE80:…..)

This means listening and broadcasting on This means listening and broadcasting on FF02::C, the link-local scope multicast address for FF02::C, the link-local scope multicast address for the link-local scope multicast address for SSDP – the link-local scope multicast address for SSDP – DefaultDefault

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).

Page 25: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

UPnP Samples Samples in Windows CE .Net

Devices:

Internet Gateway DeviceInternet Gateway Device Implements required schema and interacts

with an actual Gateway implementation. Fully functional IGD – UPnP certified

Control Point:

Universal Control Point sampleUniversal Control Point sample

Page 26: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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

Page 27: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

PB Configurations

Residential_gateway

PDA

Web Pad Enterprise

Page 28: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

Building Windows CE based Building Windows CE based Residential Gateway Image Residential Gateway Image with UPnP Internet Gateway with UPnP Internet Gateway DeviceDevice

Miro JuricMiro JuricSoftware Design Engineer/TestSoftware Design Engineer/TestWindows CEWindows CE

Page 29: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

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

Page 30: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

Questions?

Page 31: Windows CE.net SDK Miro Juric Software Design Engineer/Test Microsoft

For the interconnected lifestyle