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:
onWake
This thread has 4 replies. Displaying all posts.
Post 1 made on Saturday February 27, 2021 at 17:07
Fischi
Long Time Member
Joined:
Posts:
January 2011
114
Hi,
I‘m using the following script to show a snapshot from my AXIS camera on my Pronto TSU:


var socket = new TCPSocket();
var receivedData = "";

socket.onConnect = function() {
System.print ("TCP-IP Connected");
socket.write("GET /axis-cgi/jpg/image.cgi?resolution=CIF&camera=3&compression=10&clock=0&date=0&text=0" + " HTTP/1.1\r\n\r\n");
};

socket.onData = function() {
receivedData += socket.read();
System.print ("Tcpip Data Received:"+ receivedData);
};

socket.onIOError = function (x) {
GUI.widget("panel").label = "IOError " + x;
System.print ("Tcp Error:"+ x);
};

socket.onClose = function () {
// remove the HTTP info from received data
var imageStartIndex = receivedData.indexOf("\r\n\r\n");
var bitmapData = receivedData.substring(imageStartIndex+4);

// display the image
var MyImage = new Image(bitmapData);
GUI.widget("panel").setImage(MyImage);
};

socket.connect("192.168.83.25", 80, 3000);

I want to use onWake to renew the connection to my camera when the Pronto awakes.

How to do this in detail ?

Best regards,
Fischi
Post 2 made on Saturday February 27, 2021 at 20:04
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,992
Several questions:

The socket code you have here is basically an Image reader which is also supported by the Philips HTTP Library. Do you have that library and have you tried using it?

Is the code above in a button or in a page script?
It makes a difference due to the variable scoping of 'socket'.

Have you attempted any of the examples from the Dev Guide thus far and did you encounter any specific errors?
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 3 made on Sunday February 28, 2021 at 07:21
Fischi
Long Time Member
Joined:
Posts:
January 2011
114
On February 27, 2021 at 20:04, Lyndel McGee said...
Several questions:

The socket code you have here is basically an Image reader which is also supported by the Philips HTTP Library. Do you have that library and have you tried using it?

Is the code above in a button or in a page script?
It makes a difference due to the variable scoping of 'socket'.

Have you attempted any of the examples from the Dev Guide thus far and did you encounter any specific errors?

Hi Lyndel,

here is the specific script I'm using and it runs OK :

var socket, receivedData;
socket = new TCPSocket();
receivedData = "";

socket.onConnect = function() {
socket.write("GET /images/hspi_ultranetcam3/snapshots/NetCam001/last_snapshot.jpg HTTP/1.0\r\n\r\n");
};

socket.onData = function() {
receivedData += socket.read();
};

socket.onIOError = function (e) {
widget("output").label = "press MENU button to update !";
};

socket.onClose = function () {
var imageStartIndex,
bitmapData,
myImage;

// remove the HTTP header from the received data
imageStartIndex = receivedData.indexOf("\r\n\r\n");
bitmapData = receivedData.substring(imageStartIndex+4);

// make and display the image
myImage = new Image(bitmapData);
widget("output").setImage(myImage);
};
socket.connect("192.168.178.31", 81, 3000);


This code is in a page script and I use it as it is, not with Http Library.
I don't have attempted any of the examples from the Dev Guide until now.

Clicking on the MENU button causes a 4 seconds wait and then calling again this page with the code and a refresh in that way.
It would be nice to do this automatically onWake.



Kind regards,
Fischi
Post 4 made on Sunday February 28, 2021 at 18:48
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,992
If you can, please email mail me a small config with only the specific activity/pages in question if possible.

If the code is in a page script, then the Menu button must be executing a Jump Action to this specific page?

If you would like me to update this code to use the Philips HTTP Library, please let me know and I will do so.

FYI, the issue with onSleep/onWake is that the 'this' scope in Javascript is the Activity object and it does not down-scope to a page. That's why I asked you if you had tested the examples in the Dev Guide. :-)

Thanks,
Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 5 made on Monday March 1, 2021 at 12:31
Fischi
Long Time Member
Joined:
Posts:
January 2011
114
Thanks Lyndel,
I've sent you a PM.

Regards,
Fischi


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