Post topics, source code that relate to the Arduino Platform

User avatar
By simondid
#50403 hey

so i'v been traying to make a http post to a sonos device i goth this wokring in java the following code controles the volume level off a sonos device
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();


i'm traying to port this code to work on a esp8266

the importen pars are that i connect the this url
http:// ipAdress :1400/MediaRenderer/GroupRenderingControl/Control

and post the following

<?xml version="1.0" encoding="utf-8"?>

<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\">
<InstanceID>0</InstanceID>\n
<DesiredVolume>50</DesiredVolume> \n
</u:SetGroupVolume>\n
</s:Body>\n
</s:Envelope>


in java i set a requestmetode as post and a requestproperty as with a key called SOAPACTION
and a value as \urn:schemas-upnp-org:service:GroupRenderingControl:1#SetGroupVolume\