Post 6 made on Sunday July 17, 2022 at 16:16 |
randman Long Time Member |
Joined: Posts: | June 2003 424 |
|
|
Thanks for the info, Lyndel. I'm thinking there's 2 scenarios where I'll need to communicate with the madVR:
1. From a madVR activity: In this scenario, I'll want to maintain a connection, and any feedback that I get from the madVR will be displayed in a Pronto widget. Upon entering the activity, call a function that sets up the connection:
socket = new TCPSocket(false); // asynchronous socket Then, setup the onConnect, onData, onClose, onIOError functions.
I'll also have to handle, at the activity level (CF.activity()): onSleep, onWake and onExitCallback.
This is similar to what I did years ago when controlling TiVo via TCP. One difference, though, is, as you pointed out, the heartbeat that madVR requires. For this, I was thinking of using:
CF.activity().scheduleAfter(MS_BETWEEN_ATTEMPTS, sendHeartbeat);
Inside the sendHeartbeat function, I would again call scheduleAfter to schedule the next heartbeat to be sent. I'm wondering how to ensure that I don't inadvertently schedule more than one timer at a time...
If the Pronto goes to sleep right after I schedule a 20 second timer, I suppose the timer will still be called about 20 seconds after the Pronto wakes up??
2. From a non-madVR activity: for example, I need to send the madVR commands from my Apple TV activity or Nvidia Shield activity. In this scenario, I only need to send an occasional command (such as maybe when switching to that activity). So, I was thinking of just establishing synchronous socket like:
var socket = new TCPSocket(true); // true for synchronous
In this scenario, I would open the socket, establish a connection, write to it, and then close it (I don't think I'll need to even read from the socket... just assume the command worked).
Your proxy in a Raspberry Pi seems interesting, but if I can model what I need to do based on what I had done for the TiVo before, it might be easier for now since I can use the TiVo code as the starting point. The main difference is the need for a heartbeat timer.
EDIT: I don't have a TSU9600. I've thought about getting one in the past, but I like the one-handed operation of the TSU9400, and I didn't want to have to redo all the graphics that I've done for the TSU9400 (although a TSU9600's higher resolution would be nice when showing feedback from a madVR).
|
|
|