UPnP 设备描述文件和服务描述文件

对于一个设备来说,无论是客户端还是服务端,接入网络后,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);
}
 
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值