More Sony Bravia Stuff

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
15 reacties
    • mendel129 zei:

      nope, but i will check asap! 😉

  1. Thank you. I tried to sniff out the commands myself but hit a dead end.

  2. Alex M zei:

    Anu luck with the direct app launching?

  3. Marcus V zei:

    You wrote:
    “Once without basic auth and once with basic auth and password the number shown on the television itself…”

    I can’t really follow your example.

    So first you create the Webrequest,
    Then you open the request stream and write the Content of “jsontosend” to the TV and read the response.

    Then the key should appear on the screen.
    And then you set httpWebRequest.Headers[“Authorization”] = “Basic ” + authInfo; and write the Content of “jsonString” again the the TV.

    Did I get this correct?

      • Marcus V zei:

        The link does somehow not work 😉
        If I search for “braviacontroller” I get no result on CodePlex.

        • mendel129 zei:

          forgot to press “publish” 🙂

  4. Marcus V zei:

    Thank you for the sources! That makes it clearer. 🙂

    A short question: Is it necessary to register with the TV when just sending commands via UPnP X_SendIRCC action,or does this work without registration?

    • mendel129 zei:

      For only x_sendircc you don’t need to register. 🙂 Only to send text you need to register… (weird)

      • Alex M zei:

        To send Text AND to send direct Input commands you need to register.

        • mendel129 zei:

          that’s correct! and probably to start apps as well… Basically, everything you can do using X_SendIRCC can be done unregistered, everything that needs json needs registration. Will test today!

Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit / Bijwerken )

Twitter-afbeelding

Je reageert onder je Twitter account. Log uit / Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit / Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit / Bijwerken )

Verbinden met %s

%d bloggers liken dit: