Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
Very Basic Control using TCP/IP (Ithink!)
This thread has 6 replies. Displaying all posts.
Post 1 made on Tuesday June 22, 2010 at 05:40
zedmtrappe
Long Time Member
Joined:
Posts:
July 2008
35
Hi - I think this should be quite simple to do but so far is eluding me!

I've got Spotify (music streaming app) running on a PC with an IP address of 192.168.1.4

Also on this machine I have an app called 'Spotify Remote' which is a webserver program running on port 8080, which allows very basic control of Spotify from any browser enabled device on the network:

Simply type the following commands into the browser for control:

192.168.1.4:8080/playpause
192.168.1.4:8080/next
192.168.1.4:8080/previous

( took the http:// out so they didn't show up as links)


Would it be possible to have ProntoScript 'send' these commands from a TSU9600? (TSU9600 on the same network with IP 192.168.1.203)

I'm a complete newb when it comes to TCIP etc but I was imagining something like:

var socket = new TCPSocket(true);
socket.connect("192.168.1.4", 8080, 3000);
socket.write("playpause");
socket.close();

would have worked...

or

var socket = new TCPSocket(true);
socket.connect("192.168.1.4", 8080, 3000);
socket.write("192.168.1.4:8080/playpause");// again took http// out
socket.close();

but neither do :-(

Am I close?

Any help greatly appreciated


Zack
Post 2 made on Tuesday June 22, 2010 at 06:24
BluPhenix
Long Time Member
Joined:
Posts:
December 2008
371
Well, you're a bit close.

You stated that you input those commands in a browser, with the http:// edited out. That is the key information. The device uses the HTTP protocol to communicate.

With the socket.connect you just open a communication channel between the two devices (TSU9600 and Spotify). I'll put it this way, you pick up the phone and call a number in china. Sure you're now connected to the person you want to communicate with but if you don't know chinese, you won't be able to communicate. The http protocol mentioned above is the chinese language.

Fortunately for you philips added a HTTP library in the PEP2 editor. Take a look at it and it's usage and you will be able to do what you're looking for.

I haven't used it yet but I believe that getHTTP(url, callback) is all you need (the callback is what you want):

getHTTP("h*ttp://192.168.1.4:8080/playpause", some_callback_function)

Should do the trick. As you don't really need the data that the Spotify outputs, your callback function can be an empty function.

P.S.: The * in h*ttp is just to fool the forums not to link it (don't know how to turn html doce off :)

Last edited by BluPhenix on June 22, 2010 06:37.
OP | Post 3 made on Tuesday June 22, 2010 at 06:55
zedmtrappe
Long Time Member
Joined:
Posts:
July 2008
35
Thanks for your help and explanation BluPhenix - very much appreciated!

I did actually get it going with:

socket.write("GET /playpause HTTP/1.0\r\n\r\n");


But following your advice and looking at the HTTP library I'm going to do it the way you suggest - and see if I can then display the current song/artist and state of play - which is also output by the spotify web server app.

(If I can get it to do that I'll be very happy!)

Cheers

Zack
Post 4 made on Tuesday June 22, 2010 at 08:50
BluPhenix
Long Time Member
Joined:
Posts:
December 2008
371
True, with socket.write("GET /playpause HTTP/1.0\r\n\r\n"); you can trick the device to think you're trying to make a connection. This is the start of the http header, but then you need to "close" the http protocol to avoid tricky behavior in the http controlled device.

Glad to help.
OP | Post 5 made on Tuesday June 22, 2010 at 10:26
zedmtrappe
Long Time Member
Joined:
Posts:
July 2008
35
Got it!

Using the getHTTP business I can now control Spotify (to a limited degree) & view track and artist information !

Thanks again BluPhenix!
Post 6 made on Wednesday June 23, 2010 at 03:35
husa550
Long Time Member
Joined:
Posts:
April 2008
44
Hi zedmtrappe

How about you put that script in the files section?
I'm wery interested of testing your script!

/husa550
Post 7 made on Wednesday June 23, 2010 at 12:57
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
I actually prefer the socket write(GET . . . ) and use it all the time. It is the basic http protocol, that is it is what is sent by any browser to make a tcpip socket act using "Http protocol". I do not like to drag along libraries of code for basically simple things

As I recall a http 1.0 server will close the connection automatically after each reply where a http 1.1 server will keep it open. The suffix is to inform the server how to act. A http 1.0 server should always close the connection whereas a http 1.1 server will leave it open unless specifically tolds to act as an http 1.0 server. The wiki writeup on this and other aspects of the http protocol is very good in explaining this.


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse