Trigger open frameworks over network by php [solved]

Hi all,

I’d like to ask advice on what approach/package to use for the following task:
I have a pi with openFrameworks inside a Network. I have a Computer running a CMS (TYPO3) without openFramewoks in the same Network. I now like to trigger the pi from the CMS directly, that is, by using php/html.

I would be happy for any hints.

Thanks!
oe

Your TYPO3 app could publish a page with a message, and the raspberry could read that message.
Have a look at this ofHttpRequest and ofHttpResponse, and at some thread in the forum searching for this keywords, like this Raspberry Pi2 problems with HTTP requests

Thanks edapx!
I checked into this and it would definetely be a possibility. But if I understand correct, this means that my pi would continously call a web page, so causes traffic all day long. Because I have to work in a busy network, I hope to find a possibility where the php does the call, only if necessary. And the pi just waits for being pinged.
Is there an approach for this, too?

In this case, your Typo3 will publish a message that trig an event on the raspberry. You can use websockets http://viget.com/extend/web-interfacing-with-arduino

If you are familiar with ruby, have a look at http://blog.meinside.pe.kr/Sending-notifications-through-Pushbullet-on-Raspberry-Pi/

also ofxHttpServer and ofxHttp have an http server implementation that you can use to get pinged from another machine

I was experimenting with OSC and a wordpress backend, using http://opensoundcontrol.org/implementation/open-sound-control-php.
There is an example in test_osc_lib function.

similar to thomas’ suggestion: i’ve used a lightweight command line osc sender which was triggered from a php page using the php’s shell_exec function. (in php: shell_exec (’./oscSender localhost 7777 /doThisThing’);

The OF app used ofxOscReceiver to receive the php triggers.

Hi all, OSC is tempting but as far as I understood the php version is using UPD, not TCP as Protocol. For I have a busy network and I will need error checking this is not the way to go. I’ll learn about networks, ofxHttpServer and ofxHttp and keep you updated - in case I find a solution.

Hi all,

Thanks to all who helped me in this. Here’s what I did:
I set up an App with ofxHTTP. I basically used the example for Basic Post Server. Inside this there is a function called:

void ofApp::onHTTPPostEvent(ofx::HTTP::PostEventArgs& args)

which is triggered every time a POST form is sent. In this funtion I also get the arguments transmitted by the form. So the solution is easy in the end:
I change the form which is provided by the example to a very simple Form only using one hidden field. I then use Javascript to read the arguments I pass in an URL, fill these arguments to the hidden field and send the form.

<script type="text/javascript">
  window.onload = function(){
    var getString = window.location.search.replace("?", "");
    var getVideoID = getString.replace("videoId=", "");  
    document.getElementById('videoInputField').value=getVideoID;
    document.forms['videoForm'].submit();
  }
</script>
    
    ...
    
<form role="form" action="/post" id="videoForm" method="post" enctype="text/plain">
  <div class="form-group">
     <input type="hidden" id="videoInputField" name="run_video" value="1"></input>
  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>

So in the end I call a URL like

192.168.5.25/runVideo.html?videoId=2

Javascript reads the arguments ("?videoId=2"), prepares them, fills the value “2” in the hidden field and sends the form. In openFrameworks the function “onHTTPPostEvent” is fired, I get a string like

run_video=2

as argument. I just have to prepare it again and that’s it: I can trigger an event by calling a URL and pass on a variable at the same time.

Have a good day!
oe

1 Like

Nice!