-->
Page 1 of 1

http post / upnp on a esp9266

PostPosted: Fri Jul 08, 2016 11:37 am
by simondid
hey

so i'm traying to make a esp9266 controle my sonos devices i goth som code working in java witch i'm now traying to port to the esp8266 using arduino ide / code

here is my java code

Code: Select all     URL url = new URL("http://" + ipAdress + ":1400/MediaRenderer/GroupRenderingControl/Control");

            HttpURLConnection request = (HttpURLConnection) url.openConnection();

            request.setRequestMethod("POST");

            request.addRequestProperty("SOAPACTION", "\"urn:schemas-upnp-org:service:GroupRenderingControl:1#SetGroupVolume\"");
            request.setDoOutput(true);
            request.setReadTimeout(2000);



            OutputStreamWriter input = new OutputStreamWriter(request.getOutputStream());

            input.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                    "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
                    "   <s:Body>\n" +
                    "      <u:SetGroupVolume xmlns:u=\"urn:schemas-upnp-org:service:GroupRenderingControl:1\">\n" +
                    "         <InstanceID>0</InstanceID>\n" +
                    "         <DesiredVolume>"+volume+"</DesiredVolume>\n" +
                    "      </u:SetGroupVolume>\n" +
                    "   </s:Body>\n" +
                    "</s:Envelope>");
            input.write("");



            input.flush();




the main thing in the above java code is the i connect to this local ip addres
http://192.168.1.118:1400/MediaRenderer/GroupRenderingControl/Control


then i make a http call
witch has a request metod set as
POST

and i add i requestproperty with the key
SOAPACTION
and a value as
\urn:schemas-upnp-org:service:GroupRenderingControl:1#SetGroupVolume\


then i make a outputstream with sende the following

<?xml version=\"1.0\" encoding=\"utf-8\"?>\n
<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n
<s:Body>\n
<u:SetGroupVolume xmlns:u=\"urn:schemas-upnp-org:service:GroupRenderingControl:1\">\n
<InstanceID>0</InstanceID>\n
<DesiredVolume>50</DesiredVolume>\n
</u:SetGroupVolume>\n
</s:Body>\n
</s:Envelope>



any idear on how i can archive this with arduino code?