430 likes | 1.01k Vues
Plug And Play For Network Connected Devices. Cameron Brodeur and Kristina Hotz Program Managers Windows Device Experience Group Microsoft Corporation. Session Outline. Discusses generic resource discovery and how to turn a Network Connected Device (NCD) into a Plug and Play (PnP) device
E N D
Plug And Play For Network Connected Devices Cameron Brodeur and Kristina HotzProgram ManagersWindows Device Experience GroupMicrosoft Corporation
Session Outline • Discusses generic resource discovery and how to turn a Network Connected Device (NCD) into a Plug and Play (PnP) device • Windows Rally Overview • Function Discovery (FD) • Plug and Play Extensions for Network Connected Devices (PnP-X) • Demo • Questions
Windows® Rally™ Program Access to Technologies Simple Unified License Technical Guidance
Windows® Rally™ Devices More secure and provide rich digital experiences Effortless to configure and maintain Reliable and simple to manage
Windows Rally Experiences Windows Rally Technologies Applications Management Interfaces Plug and Play Extensions Device Specific Drivers LLTD: QoS Extensions Quality of Service Network Map LLTD: Topology Map Windows Connect Now Wireless Setup Discovery FunctionDiscovery AV Devices UPnP NetworkedDevices Device Profile for Web Services IP Network (IPv4, IPv6) Ethernet/Wireless Windows Rally Experiences Windows Rally Technologies
Function DiscoveryGeneric resource detection Kristina HotzProgram Manager
Why Function Discovery? • Many flavors of devices and resources • USB • WSD • UPnP • Different protocols • Different discovery • Different metadata acquisition • Need abstraction layer for unification • NetBIOS • Etc.
Function Discovery (FD) • New feature in Windows Vista for resource discovery • Provides uniform API for resource discovery and metadata exchange • Is extensible allowing discovery via virtually any protocol • Can aggregate results from multiple protocols • Find NetBIOS and WSD shares with single query • Find all UPnP and WSD devices with same code
Category Manager Registry FD Architectural Overview Client Function Discovery API Query Manager Registry Provider PnP Provider SSDP Provider WSD Provider WNet Provider 3rd Party Provider Registry SetupDI API SSDP WSD WNetAPIs NativeAPIs Legend: Client Internal Components Providers Client Interface Underlying APIs
hDevInfoSet = ::SetupDiGetClassDevs ( NULL, NULL, NULL, DIGCF_ALLCLASSES ); bSuccess = ::SetupDiEnumDeviceInfo ( hDevInfoSet, dwIndex++, &sddInfoElement ); if (bSuccess) { pRootDevNode = new DevNode; pRootDevNode->guidClass = sddInfoElement.ClassGuid; if (::SetupDiGetDeviceInstanceId( hDevInfoSet, &sddInfoElement, szDevId, 2047, &dwSizeNeeded )) { pRootDevNode->pszName = new WCHAR[dwSizeNeeded]; wcsncpy( pRootDevNode->pszName, szDevId, dwSizeNeeded ); } pCurrDevNode = pRootDevNode; pCurrDevNode->pNext = NULL; while (::SetupDiEnumDeviceInfo ( hDevInfoSet, dwIndex++, &sddInfoElement )) { pCurrDevNode->pNext = new DevNode; pCurrDevNode = pCurrDevNode->pNext; pCurrDevNode->guidClass = sddInfoElement.ClassGuid; if (::SetupDiGetDeviceInstanceId( hDevInfoSet, &sddInfoElement, szDevId, 2047, &dwSizeNeeded )) { pCurrDevNode->pszName = new WCHAR[dwSizeNeeded]; wcsncpy( pCurrDevNode->pszName, szDevId, dwSizeNeeded ); } pCurrDevNode->pNext = NULL; } *ppDevNodes = pRootDevNode; } Discovery: PnP
lResult = RegOpenKeyEx( HKEY_LOCAL_MACHINE, pwszSubKey, 0, KEY_READ, &hKey); if( ERROR_SUCCESS == lResult ) lResult = RegQueryInfoKey( hKey, NULL, NULL, NULL, &dwSubKeys, NULL, NULL, &dwValues, NULL, NULL, NULL, NULL); for( DWORD i = 0; ( i < dwValues ) && ( lResult == ERROR_SUCCESS ); i++ ) { WCHAR achValueName[MAX_PATH]; DWORD cchValueName = ARRAY_SIZE( achValueName ); DWORD dwType; BYTE* pBuffer = new BYTE[MAX_PATH]; DWORD dwBufSize = MAX_PATH; lResult = RegEnumValue( hKey, i, achValueName, &cchValueName, NULL, NULL, NULL, NULL ); if( ERROR_SUCCESS == lResult ) { lResult = RegQueryValueEx( hKey, achValueName, NULL, &dwType, pBuffer, &dwBufSize ); } if ( pBuffer ) delete pBuffer; } for( DWORD i = 0; ( i < dwSubKeys ) && ( lResult == ERROR_SUCCESS ); i++ ) { WCHAR pwszNewSubKey[256]; dwSize = MAX_PATH; lResult = RegEnumKeyEx( hKey, i, szName, &dwSize, NULL, NULL, NULL, &ftWrite); if( SUCCEEDED( StringCchPrintf( pwszNewSubKey, 256, L"%s\\%s", pwszSubKey, szName))) { Result = EnumerateSubKeys( pwszNewSubKey ); } } if( hKey ) RegCloseKey( hKey ); return ERROR_SUCCESS; Discovery: Registry
Discovery: FD PnP hr = spDiscovery->CreateInstanceCollectionQuery( FCTN_CATEGORY_PNP, NULL, TRUE, spNotify, &spFunQuery ); if ( SUCCEEDED( hr )) hr = spFunQuery->Execute( &spFunInsts );
Discovery: FD Registry hr = spDiscovery->CreateInstanceCollectionQuery( FCTN_CATEGORY_REGISTRY, NULL, TRUE, spNotify, &spFunQuery ); if ( SUCCEEDED( hr )) hr = spFunQuery->Execute( &spFunInsts );
Discovery: FD WSD hr = spDiscovery->CreateInstanceCollectionQuery( FCTN_CATEGORY_WSDISCOVERY, NULL, TRUE, spNotify, &spFunQuery ); if ( SUCCEEDED( hr )) hr = spFunQuery->Execute( &spFunInsts );
FD Feature Overview • Discovery • Query by protocol category insteadof with protocol code • Refine query using properties or constraints (i.e., PnP Interface IDs) • Define aggregate categories to • Target more than one provider • I.e., NetBIOS and WSD • Always apply constraints • Category will only return network printers
FD Feature Overview • Notifications • Clients receive notifications from category • Send on resource add/remove • Activation • Instantiate and initialize software objects associated with resource • Application provides the ClassID and interface desired • FD binds object to resource
The Function Instance (FI) • Single unit of discovery • Represents the discovered resource • Created by the provider in responseto a query • Local resources returned as collectionof Function Instances • Network resources returned as discovered via notifications
The Function Instance (FI) • Store resource information as properties • Store contains • Metadata • Configuration data • State data • Exposed through IPropertyStore interface • Allow read and write (when supported)of resource information
PnP-XPlug and Play for networked devices Cameron BrodeurProgram Manager
Device Connectivity Options • Windows provides many different options for device connectivity • Wired buses • USB 1.x and 2.0 • IEEE 1394 • Wireless personal area network • Bluetooth • Ultra-Wideband (UWB) • IP connected • Wi-Fi • Ethernet
HistoricallyDual approach • The IP “bus” is handled differently from other buses • This presents several problems • Disparate programming models • No single end-user experience • The device experience depends on the connector selected Undefined experience whenplugging into this port Well understood experiencewhen plugging into this port IP devices limited in adoption Custom solutions for integrating with Windows A non-PnP device Fuels device adoption Lowers support costs A PnP device
IP Network Directly Connected The FutureSingle model • Unification of IP and directly connected devices • Users should not have to care about the bus
Benefits • NCDs are simple to discover and use • Installed and managed just like local, bus-attached devices • Lower support costs • Broader device adoption • NCDs can be enumerated and accessed using standard Windows application programming interfaces (APIs) • Allows use of FD API and legacy APIs • Improved end-user experience
Benefits • NCDs benefit from existing Windows assets for device management • Windows PnP and device management infrastructure • Windows Update
Discovery • Before a device can be installed,it must be discovered • Network protocols replace the bus-specific electrical signals used for physically connected devices • Metadata exchange • Enough information about the device mustbe retrieved for installation purposes • Hardware ID • Class ID • Friendly Name • Etc.
Association • With physical connections, the cable itself establishes the association • For NCDs, the following questions apply • With which PC is the device associated? • Can the device be associated with more than one PC?
Enabling A Single Model Through PnP • The framework for enabling a single connectivity model already exists today: It’s Windows PnP (Plug and Play) • An IP bus enumerator (IPBusEnum) enumerates NCDs • A PDO is created for each enumerated device • PnP handles the installation of the device like any other device • The enabling components are collectively called PnP-X: PnP extensions for NCDs PnP Class Drivers IPBusEnum PCI USB 1394 PCMCIA Physical Discovery Network Discovery
How PnP-X Works List of device FIs returned to Network Explorer Network Explorer displays discovered devices Devices respond to multicast request FD creates a Function Instance (FI)for each device PnP-X devices presented as “Installable” User selects device for installation Network Explorer adds the FI to the Association Database, which is maintained as a FD category FD notifies IPBusEnum service that a new device has been added to Association Database IPBusEnum gathers data from FI and device Creates PnP device node (DevNode) • PnP begins device install • Finds matching INF file • Loads device driver and software • User opens Network Explorer • Multicast sent by discovery providers Network Explorer UI PnP PnP Association Database IPBusEnum DevNode Xbox FI Printer FI Storage FI Function Discovery API Network Discovery Providers DeviceDriver WSD WSD WSD SSDP SSDP SSDP 3rd Party 3rd Party Legend: PnP-X Function Discovery Network Providers Driver
How PnP-X Works Applications now see the device as unavailable Queries to PnP reflect offline state • Device starts-up • Sends WSD Hello or SSPD Alive message • FD creates FI for device; IPBusEnum notified • IPBusEnum checks association database • Matching device found in database PnP DevNode recreated Device driver loaded Applications now see the device as available Queries to PnP reflect online state • IPBusEnum calls PnP • Driver unloaded • PnP DevNode removed • Device goes offline • Sends WSD Bye or SSDP Bye-Bye message Network Explorer UI PnP PnP StorageDevice AssociationDatabase IPBusEnum DevNode StorageFI Function Discovery API Network Discovery Providers DeviceDriver WSD WSD WSD SSDP SSDP SSDP 3rd Party 3rd Party Legend: PnP-X Device startupAlive message sent Device shutdown Bye message sent Function Discovery Network Providers Driver Status: OFFLINE Status: ONLINE
Inbox Protocol Support • Inbox support is provided for the following discovery protocols in Windows Vista • Web Services Discovery Protocol (WS-Discovery) • Part of the Web Services on Devices suite of protocols • Devices must support WS-Discovery as well as the Device Profilefor Web Services to be installable by PnP-X • Simple Services Discovery Protocol (SSDP) • Used by UPnP for device discovery • Devices must support SSDP as well as Device Descriptionto be installable by PnP-X • Support for additional protocols can be enabled through the installation of a FD provider • Must conform to the requirements in the PnP-Xand FD specifications • See PnP-X and FD documentation for details
Device Requirements • Devices must support one of the inbox protocols or provide a custom provider • Devices must include additional XMLdata in the discovery metadata <HardwareId> <CompatibleId> <DeviceCategory> • Allows PnP-X to recognize that the device is “installable” and create a PnP DevNode
Device-Side XML Example (UPnP) <?xml version="1.0" ?> <root xmlns="urn:schemas-upnp-org:device-1-0"> <specVersion> <major>1</major> <minor>0</minor> </specVersion> <URLBase>http://192.168.0.1:1234</URLBase> <device> <pnpx:X_hardwareId>MSFT_MediaPlayer_HWID</pnpx:X_hardwareId> <pnpx:X_compatibleId>MSFT_MediaPlayer_CPID</pnpx:X_compatibleId> <pnpx:X_deviceCategory>MediaDevices</pnpx:X_deviceCategory> <deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType> <friendlyName>Microsoft Advanced Media Player</friendlyName> <manufacturer>Microsoft</manufacturer> ... </device> </root>
DevNode Creation • IPBusEnum creates a PnP DevNode for the device • Information discovered about the device is stored in the DevNode property store, including • IP Address • Hardware IDs and Compatible IDs for the device • Device UUID (GUID) • PnP installs a driver using the “standard” process • Search driver packages (INF files) looking for the best match based on hardware and compatible IDs • Invoke the specified class installer and optional co-installer to carry out the installation process
Device Driver Details • Manufacturer can supply a kernel-modeor user-mode driver for the device • Driver can also be a class driver supplied by Microsoft • For proprietary devices or devices that are tiedto a single application, the install process can simply install the application or service
Communicating With Your Device • Base-level functionality for an associated network connected device simply returns the IP address of the device • Communication with network connected devices will go through existing network stacks • .NET Framework • WSD • UPnP • WinSock • Protocol choice left up to the vendor
Industry Adoption • PnP-X adoption is growing • WSD-based printers • Wi-Fi digital cameras • Media Center Extender devices, including the Xbox 360 • Network Attached Storage devices • Adoption is accelerating • The time to consider PnP-X for your networked devices is now
Call To Action • Evaluate PnP-X and Function Discovery for your NCDs • Review the PnP-X and Function Discovery documentation on MSDN • For WSD and UPnP devices, update your device to provide the information specifiedby the PnP-X documentation • For other devices, write a Function Discovery provider that conforms to requirements specified by the FD documentation
Additional Resources • Web Resources • Function Discovery Specshttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/fundisc/ncd/portal.asp • PnP-X Specs See the Windows Rally SDK at http://www.microsoft.com/rally • Function Discovery SDK Documentation http://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/en-us/fundisc/ncd/about_function_discovery.asp • Whitepapershttp://www.microsoft.com/rally • Related Sessions • Web Services on devices in Windows Vista • Web Services on devices: The protocol now and for the future • Email address for more information rally @ microsoft.com
© 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.