archiveren

Tagarchief: 2013

So, model 2013 revealed some more secrets!

using Newtonsoft.Json;
using ManagedUPnP;

Finding all upnp services on the current network

Services lsServices = Discovery.FindServices(null,timeout, 0,out lbCompleted,AddressFamilyFlags.IPvBoth);

And filter out the ones being Sony.

foreach (Service IndividuallsService in lsServices)
{
if (IndividuallsService.Description().Actions.ContainsKey("X_SendIRCC"))
{
sony bravia television found! :-)
sonytv=IndividuallsService;
}
}

Register to the device by calling webservice (json) twice! Once without basic auth and once with basic auth and password the number shown on the television itself! Catch the cookie, because it contains the authentication key! (With expiration date 00-00-0000).
Using the same json.net library, you can easily serialize the cookiecontainer for later use.

string hostname = System.Windows.Forms.SystemInformation.ComputerName;
string jsontosend = "{\"id\":13,\"method\":\"actRegister\",\"version\":\"1.0\",\"params\":[{\"clientid\":\"" + hostname + ":11c43119-af3d-40e7-b1b2-743311375322c\",\"nickname\":\"" + hostname + " (Mendel's APP)\"},[{\"clientid\":\"" + hostname + ":11c43119-af3d-40e7-b1b2-743311375322c\",\"value\":\"yes\",\"nickname\":\"" + hostname + " (Mendel's APP)\",\"function\":\"WOL\"}]]}";


var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://"+theipadres+"/sony/accessControl");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.AllowAutoRedirect = true;
httpWebRequest.CookieContainer = allcookies;


string authInfo = "" + ":" + pincode; #pincode shown on television
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
httpWebRequest.Headers["Authorization"] = "Basic " + authInfo;
(HttpWebResponse)httpWebRequest.GetResponse();

And you can send any command using upnp. The list of commands can be found grabbing the response from the correct request (click here for known requests)

sonytv.InvokeAction("X_SendIRCC", "AAAAAQAAAAEAAABgAw==");

Or the special commands using json

string jsontosend = "{\"id\":78,\"method\":\"setTextForm\",\"version\":\"1.0\",\"params\":[\"http://www.mendelonline.be\"]}";

sonybravia

Advertenties

So, we’ve bought a nice Sony Bravia TV (W6), featuring the today’s “default networking” options.

But I want to control it from my Windows Phone 7 device πŸ™‚
(ofcourse!)
The current sony bravia compatible apps, don’t actually work on the new generation… So, we’re figuring out how and what the 2013 models are actually capable off!

So, where to start…
Sony has it’s own official app for android, and everything works fine…
When you combine this with WireShark, or at least tcpdump, this gives a very nice insight in what happens.

So, after trying some things out on my tablet, I started analysing the results from tcpdump.

First results came out like this: http://mendelonline.be/sony/sony.txt

A rest interface listens on an http-webserver, while upnp-traffic goes on 52323.

Using a rest client, https://addons.mozilla.org/En-us/firefox/addon/restclient/, you can run some commands, and simulate the commands from above
restclient

Next in the house comes Intel’s Device Spy for UPnP technologies, or a more up to date versions from https://sites.google.com/site/opensoftwareprojects/dev-tools-for-upnp

upnpspyAnd there you notice the function “X_SendIRCC”.
This in combination with the commands we found above enables us to do what we want πŸ™‚

For the moment I’ve teamed up withΒ etrosce from BraviaControl and Falco from Sony Virtual Remote Control to figure out what’s going on!
Sony Virtual Remote Control actually works (it has a cached version of the earlier found commands),
So, if we can “port” it somehow to WP7, things would be cooool πŸ™‚

Anyway, I’ll keep you posted!