概述
对于一个设备来说,无论是客户端还是服务端,接入网络后,UPnP经历下列过程:
* 获取自己的IP地址,无论是通过dhcp或者手动设置。
* 组播M-SEARCH/*-NOTIFY。
*获取Loacation指定的设备描述文件, 服务描述文件。
*从描述的service/actions/events中选择自己感兴趣的。
# 设备描述文件模板
<?xml version="1.0"?>
<rootxmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<URLBase>base URL for all relative URLs</URLBase>
<device>
<deviceType>urn:schemas-upnp-org:device:deviceType:v</deviceType>
<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>
<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>
<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 defined by a UPnP Forum working
committee (if any) go here
Declarations for other services added by UPnP vendor (if any) go here
</serviceList>
<deviceList>
Description of embedded devices defined by a UPnP Forum working
committee (if any) go here
Description of embedded devices added by UPnP vendor (if any) go here
</deviceList>
<presentationURL>URL for presentation</presentationURL>
</device>
</root>
UDN -- Unique Device Name
SCPDURL -- Service Control Protocol Document, URL for service description of SOAP methods and state variables.
controlURL -- used for sending SOAP requests.
eventSubURL -- when a state variable is changed, the new state is sent to all programs/devices that have subscribed to the event.
# 例子
DeviceDescription.xml
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:BinaryLight:1</deviceType>
<friendlyName>UPnP Binary Light</friendlyName>
<manufacturer>MyCompany</manufacturer>
<manufacturerURL>www.mywebsite.org</manufacturerURL>
<modelDescription>New brilliant BinaryLight</modelDescription>
<modelName>SuperWhiteLight 4000</modelName>
<modelNumber>1</modelNumber>
<UDN>uuid:138d3934-4202-45d7-bf35-8b50b0208139</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:SwitchPower:1</serviceType>
<serviceId>urn:upnp-org:serviceId:SwitchPower:1</serviceId>
<SCPDURL>switchpower_scpd.xml</SCPDURL>
<controlURL>/control</controlURL>
<eventSubURL>/eventing</eventSubURL>
</service>
</serviceList>
</device>
</root>
-->
switchpower_scpd.xml:
<?xml version="1.0"?>
<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<actionList>
<action>
<name>SetTarget</name>
<argumentList>
<argument>
<name>newTargetValue</name>
<relatedStateVariable>Target</relatedStateVariable>
<direction>in</direction>
</argument>
</argumentList>
</action>
<action>
<name>GetTarget</name>
<argumentList>
<argument>
<name>RetTargetValue</name>
<relatedStateVariable>Target</relatedStateVariable>
<direction>out</direction>
</argument>
</argumentList>
</action>
<action>
<name>GetStatus</name>
<argumentList>
<argument>
<name>ResultStatus</name>
<relatedStateVariable>Status</relatedStateVariable>
<direction>out</direction>
</argument>
</argumentList>
</action>
</actionList>
<serviceStateTable>
<stateVariable sendEvents="no">
<name>Target</name>
<dataType>boolean</dataType>
<defaultValue>0</defaultValue>
</stateVariable>
<stateVariable sendEvents="yes">
<name>Status</name>
<dataType>boolean</dataType>
<defaultValue>0</defaultValue>
</stateVariable>
</serviceStateTable>
</scpd>
相当于
public interface SwitchPower{
boolean Target = 0;
boolean Status = 0;
void SetTarget(boolean newTargetValue);
boolean GetTarget(void);
boolean GetStatus(void);
}
最后
以上就是受伤马里奥为你收集整理的UPnP 设备描述文件和服务描述文件的全部内容,希望文章能够帮你解决UPnP 设备描述文件和服务描述文件所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复