Archive:Configure Sony PS3 remote on Asus EB1012P and JSON-RPC API: Difference between pages

From Official Kodi Wiki
(Difference between pages)
Jump to navigation Jump to search
>Sjefen6
No edit summary
 
>Montellese
m (moved JSON RPC to JSON-RPC API: correct term is "JSON-RPC")
 
Line 1: Line 1:
OBS: this is written after the fact and by memory. prosseed with cusion
JSON-RPC is a HTTP- and/or raw TCP socket-based interface for communicating with XBMC. It replaces the soon-to-be-depreceated HTTP API, and offers a more secure and robust mechanism in the same format. It is based upon the [http://jsonrpc.org/spec.html JSON-RPC 2.0 specification].


Hardware:
Each method in the interface can have different security needs which means one client may be allowed to only control playback while another can only read and manipulate the library. In version 2 (first stable) and 4 all clients are granted full authority but will later be forced to ask for privileges and the user of XBMC will have to grant said client access. The design of JSON-RPC is that most methods should behave roughly the same and maintain consistency while hiding the mechanics of XBMC from the client creator.
<ul>
<li>Asus eee box eb1012p</li>
<li>Bluetooth dongle</li>
<li>Sony PS3 blueray remote</li>
</ul>
Hardware requiered for installation:
<ul>
<li>1 GB or more USB memorystick for installation</li>
</ul>
Optional Hardware
<ul>
<li>16 GB or more USB memorystick for backing up Win 7</li>
</ul>
Software:
<ul>
<li>GNU/Linux, Ubuntu Lucid Lynx 10.04</li>
<li>XMBC Dharma 10.0 Beta 2</li>
</ul>
Issues:
<ul>
<li>HDMI Audio - Not Resolved</li>
<li>Posibillety to log stight into an xbmc session with remote, and change the session type (before logging in) to gnome with keyboard and mice - Not Resolved</li>
<li>Vertical Tear when using VGA - Solved</li>
</ul>
Step by step walkthrough:


Backup Win 7 in case I want it back (Also avaiable in pamflet included with the pc)
In XBMC JSON-RPC can be accessed over a variety of transports and has been designed from the ground up to be flexible to allow control over new transports easily. Some of the transports have different limitations which will be enforced upon the interaction over that transport. As an example HTTP transports allow response and downloading of files while the raw TCP transport allows response and notifications (events and information XBMC sends to its clients). Depending on the client's needs it will choose one (or many) of the available transports.
<ol>
 
<li>Enter bios (F2) and disable Boot Booster</li>
==Enabling JSON-RPC==
<li>Reboot and press F9</li>
Since the interface is available on many transports enabling it depends on the transport.
<li>Select Windows setup [EMS Enabled]</li>
* Python: Always enabled
<li>Select Backup the Factory Environment to USB Drive (use the optional 16 GB or more USB memorystick)</li>
* HTTP: In System/Settings/Network/Services activate ''Allow control of XBMC via HTTP''
<li>To restore; please refer to the pamflet included with the pc</li>
* TCP: In System/Settings/Network/Services activate ''Allow programs on this system to control XBMC'' for localhost access only and ''Allow programs on other systems to control XBMC'' for access from other computers as well
</ol>
 
Create an bootable USB memorystick
Note: The EventServer is a different interface for sending remote keypresses to XBMC, and must be enabled separately, some programs may use both interfaces.
<ol>
 
<li>[https://help.ubuntu.com/community/Installation/FromUSBStick#From%20Ubuntu%20Linux In ubuntu] can you install "usb-creator" and run this software from System/Administration/Startup Disk Creator</li>
==Transports==
<li>Boot form the memorytick by pressing F8</li>
===Functionalities===
<li>Follow the install instructions on screen</li>
TODO
<li>Once the installation is complete is it time for some fickeling</li>
 
<li>Enable the latest ubuntu communety driver in "System/Administration/Hardware Drivers"</li>
===Comparison===
</ol>
The following table shows all the available transports and what functionalities they support
[Optional] Install the latest nVidia Driver
{| class="wikitable" style="margin-right:0; font-size:85%;"
<ol>
!style="width:15em"|
<li>Reboot after enabeling the community driver</li>
 
<li>Download the latest "driver" from nVidias homepage, I used this http://www.nvidia.co.uk/object/linux-display-ia32-256.53-driver-uk.html</li>
!Response
<li>Save the file in you user directory (~) for easy access</li>
!Notifications
<li>Exit all applications and press Ctrl+Alt+F1 to enter the terminal</li>
!Direct file download
<li>Stop gdm with the sommand</li>
!Redirected file download
<pre>sudo /etc/init.d/gdm stop</pre>
|-
<li>Ignore the error message</li>
|[[Python Development|Python]]
<li>Install the driver by using the command</li>
|{{yes}}
<pre>sh NVIDIA-Linux-x86-256.53.run (the filename might change for other driver versions)</pre>
|{{yes}}
<li>If you are given an error, try to resove it, and/or press forward</li>
|{{no}}
<li>If the installation was a success, please continue.</li>
|{{no}}
<li>Retart gdm with the command:</li>
|-
<pre>sudo /etc/init.d/gdm start</pre>
|[http://en.wikipedia.org/wiki/Transmission_Control_Protocol TCP]
<li>Reboot the computer to settle everyting into place</li>
|{{yes}}
</ol>
|{{yes}}
Add some usefull reposetorys:
|{{no}}
<ol>
|{{no}}
<li>Open a Terminal window and type:</li>
|-
<pre>sudo nano /etc/apt/sources.list</pre>
|[http://en.wikipedia.org/wiki/HTTP HTTP]
<li>Add the following lines to the end of the file:</li>
|{{yes}}
<pre>deb http://ppa.launchpad.net/kitlaan/ppa/ubuntu lucid main
|{{no}}
deb-src http://ppa.launchpad.net/kitlaan/ppa/ubuntu lucid main
|{{no}}
deb http://ppa.launchpad.net/team-xbmc-svn/ppa/ubuntu lucid main
|{{yes}}
deb-src http://ppa.launchpad.net/team-xbmc-svn/ppa/ubuntu lucid main
|-
deb http://ppa.launchpad.net/team-xbmc/xbmc-ppa-build-depends/ubuntu lucid main
|}
deb-src http://ppa.launchpad.net/team-xbmc/xbmc-ppa-build-depends/ubuntu lucid main</pre>
 
<li>NB! There are better ways of doing this. I dont remember the commands, but they will allso add the gpg key.I think it is using "sudo add-apt-repository" Anyone know them?</li>
==API versions==
</ol>
The JSON-RPC API exposed by XBMC is constantly extended to provide better and more functionality to third party applications. For that reason XBMC provides a version information through the '''JSONRPC.Version''' method. The rule is that odd version numbers describe an API state, that is not stable and under heavy development whereas even version numbers describe a stable API. Therefore the version number can be used by third party clients to check if their application might not be fully compatible with the JSON-RPC API exposed by a users XBMC installation.
Getting the PS3 controller working: This is based of the xbmc wiki http://wiki.xbmc.org/index.php?title=HOW-TO_Setup_PS3_BD_Remote
 
<ol>
Since the first release of the JSON-RPC API in XBMC 10.0 (Dharma) there have been the following versions of the API:
<li>Open a Terminal windows and type:</li>
* [[JSON-RPC/v2|JSON-RPC v2 (Dharma)]]
<pre>sudo apt-get update &amp;&amp; sudo apt-get upgrade</pre>
* [[JSON-RPC/v3|JSON-RPC v3 (pre Eden)]]
<li>This should upgrade bluez, look for it!</li>
 
<li>type:</li>
==Documentation==
<pre>sudo nano /etc/modules</pre>
TODO
<li>Add this line to the end of the file:</li>
 
<pre>uinput</pre>
==Debugging==
<li>Reboot the computer to let things settle down</li>
===Output format===
<li>Open a Terminal window and type these commands:</li>
To be able to support easier debugging of (third party) development using the JSON-RPC API, the JSON output generated by XBMC can be pretty printed by setting
<pre>cd ~
<source lang="xml">
wget http://kitlaan.twinaxis.com/holdingcell/ps3pair.tar.gz tar xvfz ps3pair.tar.gz
<jsonrpc>
cd ~/ps3pair
    <compactoutput>false</compactoutput>
sudo python ps3_pair.py</pre>
</jsonrpc>
<li>Hold down START + Enter on the Remote and you should be able to add it</li>
</source>
<li>Some checks to see of it was added correctly:</li>
in the [[Advancedsettings.xml#.3Cjsonrpc.3E|advancedsettings.xml]]. Default JSON output will be in compact format to minimize sent data (especially useful for mobile devices).
<pre>/usr/share/doc/bluez/examples/list-devices
 
cat /proc/bus/input/devices | grep emot</pre>
===Direct interaction===
<li>Both commands should show the Sony BD Remote</li>
To be able to test some methods of XBMC's JSON-RPC API it can be of great help to be able to send a single hand-written JSON-RPC request to XBMC to see its effect and the generated response. Depending on the transport protocol used there are different possibilities to do that:
<li>Edit /etc/bluetooth/input.list (sudo nano /etc/bluetooth/input.list) accourding to this wiki http://wiki.xbmc.org/index.php?title=HOW-TO_Setup_PS3_BD_Remote#Example_input.conf</li>
 
<li>Try pressing the audio key on the remote in an open Terminal windows and the letter "a" should appair</li>
====TCP====
</ol>
With a '''[http://en.wikipedia.org/wiki/Telnet telnet]''' connection (using [http://en.wikipedia.org/wiki/PuTTY PuTTY] on Windows or telnet on Linux) to port 9090 of the machine running XBMC it is possible to send and receive raw json data to/from XBMC.
All well by now. Its time to install xbmc
 
<ol>
====HTTP====
<li>Open an Terminal and type:</li>
A simple way of manually sending HTTP requests containing a JSON-RPC request to XBMC is using the [http://chrome.google.com/extensions/detail/fhjcajmcbmldlhcimfajhfbgofnpcjmb Simple REST Client] extension for Google's Chrome/Chromium browser. It allows defining an URL and the HTTP request type ('''POST''' is what we need). The actual JSON-RPC request can be defined in the '''Data''' field and then sent to XBMC.
<pre>sudo apt-get install xbmc-standalone</pre>
 
<li>You might have issues here, and I would love to get feedback on this, but I upgraded from 9.11 to 10.0 and had to use the command</li>
==External links==
<pre>sudo apt-get dist-upgrade</pre>
*[http://jsonrpc.org/spec.html JSON-RPC 2.0 specification]
<li>libvdpau should allso get installed, look for it!</li>
*[http://tools.ietf.org/html/draft-zyp-json-schema-03 A JSON Media Type for Describing the Structure and Meaning of JSON Documents (Draft 03)]
</ol>
 
Fixing possible issues with vertical tear: based of this forum post: http://forum.xbmc.org/showthread.php?t=70068
[[Category:Inner Workings]]
<ol>
[[Category:Development]]
<li>Open an Terminal windows and type:</li>
<pre>sudo apt-get install curl
curl "http://pastebin.com/download.php?i=bU1QFQ3c" | tr -d \\r &gt; nvidia.sh
sh nvidia.sh</pre>
<li>Reboot the system to let everything settle down</li>
</ol>

Revision as of 21:18, 24 October 2011

JSON-RPC is a HTTP- and/or raw TCP socket-based interface for communicating with XBMC. It replaces the soon-to-be-depreceated HTTP API, and offers a more secure and robust mechanism in the same format. It is based upon the JSON-RPC 2.0 specification.

Each method in the interface can have different security needs which means one client may be allowed to only control playback while another can only read and manipulate the library. In version 2 (first stable) and 4 all clients are granted full authority but will later be forced to ask for privileges and the user of XBMC will have to grant said client access. The design of JSON-RPC is that most methods should behave roughly the same and maintain consistency while hiding the mechanics of XBMC from the client creator.

In XBMC JSON-RPC can be accessed over a variety of transports and has been designed from the ground up to be flexible to allow control over new transports easily. Some of the transports have different limitations which will be enforced upon the interaction over that transport. As an example HTTP transports allow response and downloading of files while the raw TCP transport allows response and notifications (events and information XBMC sends to its clients). Depending on the client's needs it will choose one (or many) of the available transports.

Enabling JSON-RPC

Since the interface is available on many transports enabling it depends on the transport.

  • Python: Always enabled
  • HTTP: In System/Settings/Network/Services activate Allow control of XBMC via HTTP
  • TCP: In System/Settings/Network/Services activate Allow programs on this system to control XBMC for localhost access only and Allow programs on other systems to control XBMC for access from other computers as well

Note: The EventServer is a different interface for sending remote keypresses to XBMC, and must be enabled separately, some programs may use both interfaces.

Transports

Functionalities

TODO

Comparison

The following table shows all the available transports and what functionalities they support

Response Notifications Direct file download Redirected file download
Python Yes Yes No No
TCP Yes Yes No No
HTTP Yes No No Yes

API versions

The JSON-RPC API exposed by XBMC is constantly extended to provide better and more functionality to third party applications. For that reason XBMC provides a version information through the JSONRPC.Version method. The rule is that odd version numbers describe an API state, that is not stable and under heavy development whereas even version numbers describe a stable API. Therefore the version number can be used by third party clients to check if their application might not be fully compatible with the JSON-RPC API exposed by a users XBMC installation.

Since the first release of the JSON-RPC API in XBMC 10.0 (Dharma) there have been the following versions of the API:

Documentation

TODO

Debugging

Output format

To be able to support easier debugging of (third party) development using the JSON-RPC API, the JSON output generated by XBMC can be pretty printed by setting

<jsonrpc>
    <compactoutput>false</compactoutput>
</jsonrpc>

in the advancedsettings.xml. Default JSON output will be in compact format to minimize sent data (especially useful for mobile devices).

Direct interaction

To be able to test some methods of XBMC's JSON-RPC API it can be of great help to be able to send a single hand-written JSON-RPC request to XBMC to see its effect and the generated response. Depending on the transport protocol used there are different possibilities to do that:

TCP

With a telnet connection (using PuTTY on Windows or telnet on Linux) to port 9090 of the machine running XBMC it is possible to send and receive raw json data to/from XBMC.

HTTP

A simple way of manually sending HTTP requests containing a JSON-RPC request to XBMC is using the Simple REST Client extension for Google's Chrome/Chromium browser. It allows defining an URL and the HTTP request type (POST is what we need). The actual JSON-RPC request can be defined in the Data field and then sent to XBMC.

External links