Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Network Light

Phil Schatzmann edited this pageMay 26, 2024 ·15 revisions

Device URL

The network light which is part of thegupnp-dlna-tools is a sample test application that can be used easily because it is quite simple.

We can use it to investigate the basic functionality and subsequently implement a control point example which switches the light on and off.

It announces itself viaUDP with

NOTIFY * HTTP/1.1.Host: 239.255.255.250:1900.Cache-Control: max-age=1800.Location: http://192.168.1.35:41607/836edb54-5955-49b1-8cf7-8d054e34479e.xml.Server: Linux/6.5.0-35-generic UPnP/1.0 GUPnP/1.4.3.NTS: ssdp:alive.NT: upnp:rootdevice.USN: uuid:836edb54-5955-49b1-8cf7-8d054e34479e::upnp:rootdevice.

So, the device url is available athttp://192.168.1.35:39377/62c9fe67-c027-41b9-b026-9d4c4d697345.xml

Device XML

This provides the following device XML

<?xml version="1.0"?><rootxmlns="urn:schemas-upnp-org:device-1-0"><specVersion><major>1</major><minor>0</minor></specVersion><device><deviceType>urn:schemas-upnp-org:device:DimmableLight:1</deviceType><friendlyName>GUPnP Network Light</friendlyName><manufacturer>GUPnP Developers</manufacturer><manufacturerURL>http://www.gupnp.org</manufacturerURL><modelDescription>Software emulated UPnP light bulb</modelDescription><modelName>Network Light</modelName><modelNumber>0.1</modelNumber><modelURL>http://www.gupnp.org</modelURL><serialNumber>0.1</serialNumber><UDN>uuid:62c9fe67-c027-41b9-b026-9d4c4d697345</UDN><iconList><icon><mimetype>image/png</mimetype><width>256</width><height>256</height><depth>32</depth><url>/pixmaps/network-light-256x256.png</url></icon><icon><mimetype>image/png</mimetype><width>22</width><height>22</height><depth>32</depth><url>/pixmaps/network-light-22x22.png</url></icon></iconList><serviceList><service><serviceType>urn:schemas-upnp-org:service:SwitchPower:1</serviceType><serviceId>urn:upnp-org:serviceId:SwitchPower:1</serviceId><SCPDURL>/xml/SwitchPower-scpd.xml</SCPDURL><controlURL>/SwitchPower/Control</controlURL><eventSubURL>/SwitchPower/Events</eventSubURL></service><service><serviceType>urn:schemas-upnp-org:service:Dimming:1</serviceType><serviceId>urn:upnp-org:serviceId:Dimming:1</serviceId><SCPDURL>/xml/Dimming-scpd.xml</SCPDURL><controlURL>/Dimming/Control</controlURL><eventSubURL>/Dimming/Events</eventSubURL></service></serviceList><presentationURL/></device></root>

It provides 2 Services: SwitchPower and Dimming!

Example Service SwitchPower

The SwitchPower service description XML (=SCPDURL) can be found athttp://192.168.1.35:39377/xml/SwitchPower-scpd.xml and it provides:

<?xml version="1.0"?><scpdxmlns="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><stateVariablesendEvents="no"><name>Target</name><dataType>boolean</dataType><defaultValue>0</defaultValue></stateVariable><stateVariablesendEvents="yes"><name>Status</name><dataType>boolean</dataType><defaultValue>0</defaultValue></stateVariable></serviceStateTable></scpd>

With this, we can now try to switch the power on with the help of SetTarget.

Action: SwitchPower SetTarget

This can be done with aHTTP Post to the control address

POST /SwitchPower/Control HTTP/1.1HOST: 192.168.1.35 43365CONTENT-TYPE: text/xml; charset="utf-8"SOAPACTION: "urn:schemas-upnp-org:service:SwitchPower:1#SetTarget"<?xml version="1.0"?><s:Envelopexmlns:s="http://schemas.xmlsoap.org/soap/envelope/"s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetTargetxmlns:u="urn:schemas-upnp-org:service:SwitchPower:1"><newTargetValue>1</newTargetValue></u:SetTarget></s:Body></s:Envelope>

Reply SwitchPower SetTarget

The post provides the following result:

<?xml version="1.0"?><s:Envelopexmlns:s="http://schemas.xmlsoap.org/soap/envelope/"s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetTargetResponsexmlns:u="urn:schemas-upnp-org:service:SwitchPower:1"></u:SetTargetResponse></s:Body></s:Envelope>

Action: SwitchPower GetTarget

We can also get the value with a HTTP Post to the control address

POST /SwitchPower/Control HTTP/1.1HOST: 192.168.1.35 43365CONTENT-TYPE: text/xml; charset="utf-8"SOAPACTION: "urn:schemas-upnp-org:service:SwitchPower:1#GetTarget"<?xml version="1.0"?><s:Envelopexmlns:s="http://schemas.xmlsoap.org/soap/envelope/"s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetTargetxmlns:u="urn:schemas-upnp-org:service:SwitchPower:1"/></s:Body></s:Envelope>

Reply SwitchPower GetTarget

The post provides the following result:

<?xml version="1.0"?><s:Envelopexmlns:s="http://schemas.xmlsoap.org/soap/envelope/"s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetTargetResponsexmlns:u="urn:schemas-upnp-org:service:SwitchPower:1"><RetTargetValue>1</RetTargetValue></u:GetTargetResponse></s:Body></s:Envelope>

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp