In case anyone is trying to write their own before I get my program written or wants to play around, you can modify this c# code for your own needs. My receiver is "yamaha" in my own DNS system, so you would need to replace this with your IP or DNS name. I am just using a basic windows form app with .NET 4.0, but this is easily adapted to just about anything.
All this does when "MakeRequests()" is called is rename the friendly name to "test". I did find out the unit needs to be powered on for this call to take, even with their web browser interface. It doesn't stick if the unit is powered off, so that was strange.
All the backend code for their web interface is at
Code:
http://deviceip/JavaScripts/scr0.js
http://deviceip/JavaScripts/scr1.js
I think the calls to get the parameters for the device are the following (there is probably a couple more I mised)
Code:
GetParam
GetParam
GetParam
GetParam
GetParam
GetParam
GetParam
GetParam
GetParam
GetParam
Code:
//Calls request functions sequentially.
private void MakeRequests()
{
HttpWebResponse response;
if (Request_yamaha(out response))
{
//Success, possibly use response.
response.Close();
}
else
{
MessageBox.Show("Failure"); //Failure, cannot use response.
}
}
///
/// Tries to request the URL: http://yamaha/YamahaRemoteControl/ctrl
///
///
After the function has finished, will possibly contain the response to the request.
/// True if the request was successful; false otherwise.
private bool Request_yamaha(out HttpWebResponse response)
{
response = null;
try
{
//Create request to URL.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://yamaha/YamahaRemoteControl/ctrl");
//Set request headers.
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-us,en;q=0.5");
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Add(HttpRequestHeader.AcceptCharset, "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
request.Referer = "http://yamaha/";
request.Headers.Add(HttpRequestHeader.KeepAlive, "true");
request.ContentType = "text/xml; charset=UTF-8";
request.Headers.Add(HttpRequestHeader.Pragma, "no-cache");
request.Headers.Add(HttpRequestHeader.CacheControl, "no-cache");
//Set request method
request.Method = "POST";
//Set request body.
string postString = @"" + "test" + "";
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(postString);
request.ContentLength = postBytes.Length;
Stream stream = request.GetRequestStream();
stream.Write(postBytes, 0, postBytes.Length);
stream.Close();
//Get response to request.
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
//ProtocolError indicates a valid HTTP response, but with a non-200 status code (e.g. 304 Not Modified, 404 Not Found)
if (e.Status != WebExceptionStatus.Success) response = (HttpWebResponse)e.Response;
else return false;
}
catch (Exception)
{
if (response != null) response.Close();
return false;
}
return true;
}