SSDP用于设备发现

时间:2015-06-05 13:53:26

标签: embedded hardware upnp service-discovery ssdp

我正在开发一个应该在Windows中自动发现的硬件设备,所以我更喜欢通过SSDP而不是mDNS(Zeroconf等)来避免强制用户安装其支持应用程序。 我只需要设备出现在Windows资源管理器中的网络中,然后单击它以使用URL中的设备IP地址打开默认浏览器。我已经制作了代码(在单播中回答多播M-SEARCH请求并在启动时定期发送NOTIFY消息),我可以在Windows PC上看到Wireshark中的消息,但设备仍然没有出现在资源管理器网络中文件夹,我可以看到其他设备,如我的打印机,电视,媒体播放器等,我也看到他们的消息也在Wireshark上。 我正在寻找有关通知和响应消息内容的一些建议,也在xml文件中搜索这样一个简单设备的设备配置文件 - 我只想宣传该设备的IP地址上有一个网络服务器。

这些是我发送的消息:

在多播中:

NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
NT: upnp:rootdevice
USN: uuid:c5baf4a1-0c8e-44da-9714-ef0123411223::upnp:rootdevice
NTS: ssdp:alive
SERVER: NodeMCU/20150415 UPnP/1.1 xpto/0.1
Location: http://192.168.3.246/deviceprofile.xml

单播作为对M-SEARCH的回复:

HTTP/1.1 200 OK
Cache-Control: max-age=100
EXT:
SERVER: NodeMCU/20150415 UPnP/1.1 xpto/0.1
ST: upnp:rootdevice
USN: uuid:c5baf4a1-0c8e-44da-9714-ef0123411223
Location: http://192.168.3.246/deviceprofile.xml

deviceprofile.xml:

<?xml version='1.0'?>
<root xmlns='urn:schemas-upnp-org:device-1-0'>
<device>
<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
<presentationURL>http://192.168.3.246/</presentationURL>
<friendlyName>Remote control</friendlyName>
<manufacturer>xpto.com</manufacturer>
<manufacturerURL>http://xpto.com/</manufacturerURL>
<serialNumber>10275488</serialNumber>
<UDN>uuid:c5baf4a1-0c8e-44da-9714-ef0123411223</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:Basic:1</serviceType>
<serviceId>urn:upnp-org:serviceId:1</serviceId>
</service>
</serviceList>
</device></root>

为了让设备显示在Windows资源管理器网络文件夹中,还需要其他所有内容吗?

提前致谢

费尔南多

1 个答案:

答案 0 :(得分:2)

根据UPnP规范,您的deviceprofile.xml格式不正确。 <service>标记下需要其他元素。此外,urn:schemas-upnp-org:service:Basic:1是非法的,您需要更改为预定义的UPnP或在您自己的命名空间下自定义。一个例子可能是:

<service>
    <serviceType>urn:schemas-upnp-org:service:XXXX:1</serviceType>
    <serviceId>urn:upnp-org:serviceId:1</serviceId>
    <SCPDURL>URL to service description.xml</SCPDURL>
    <controlURL>URL for control</controlURL>
    <eventSubURL>URL for eventing</eventSubURL> 
</service>

您可以查看: Part2.3 http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf

相关问题