Presentation

Presentation is the final step in the UPnP process. If a device has a URL for presentation, a control point can retrieve a page from this URL and load the page into a browser. Depending on the capabilities of the presentation page and the device, the control point can control the device and view the status of the device.

The resource path, which is passed to IUPnPRegistrar during registration, is where all the files relevant to the presentation of the device are located. Device developers can provide separate pages for each embedded device. The presentation URL in the device description template can either be an absolute URL or a relative URL. For relative URLs, which are relative to the resource path, the device description template should contain a file name. IUPnPRegistrar converts this to a URL with the actual location. For absolute URLs, the location is not modified.

To support client side scripts within a presentation page, extra information is normally appended to the URL in the form of a "query string". The extra information that is appended is the URL to the device description document, and the UDN of the device or embedded device. The device description URL can be used to load a description document in the script, and then control the device through its services. The UDN is used to select an embedded device from the root device.

The format of the modified presentation URL is: the actual presentation URL, a question mark ("?"), the device description URL, a plus sign ("+"), the device UDN. The question mark denotes the start of the query string.

If the presentation URL in the device description template was an absolute URL and it already contained a question mark ("?"), then the extra information is not added to the presentation URL.

Description URL
In the device description template presentationURLMyDevice.html**/presentationURL**
Generated by the device host presentationURLhttps://machinename/deviceID/MyDevice.html/?https://machine/upnphost/udhisapi.dll?content=uuid:487394… + UDN**/presentationURL**

 

A client-side script may have to extract the device description URL from the presentation URL to load the IUPnPDescriptionDocument object. This is done by taking the query string, and terminating it at the plus sign ("+").

Dim QueryString
QueryString = window.location.search
Dim DescURLString
DescURLString = Trim(Mid(QueryString,2,Instr(QueryString,"+")-2))& vbCrLf

    Dim LightDesc
    Set LightDesc = CreateObject("UPnP.DescriptionDocument.1")
    LightDesc.Load(DescURLString)

In the case of a presentation page for an embedded device, some additional work is required. After loading the UPnPDescriptionDocument, the script must obtain the collection of embedded devices, then select the device that matches the UDN in the query string. The following script shows how to select the embedded device for the current presentation page. It assumes LightDesc is already loaded.

Dim LightDevice
Set LightDevice = LightDesc.RootDevice

Dim EmbeddedDevices 
set EmbeddedDevices = LightDevice.Children

Dim DeviceUdnString
DeviceUdnString = Trim(Mid(QueryString,Instr(QueryString,"+")+1,Len(QueryString)))

Dim Item
set Item = EmbeddedDevices.Item(DeviceUdnString)