Question

Dummy question here but I haven't found any answer on the web for now.

I'm working on a cakephp website, installed on a Raspberry Pi, which is supposed to be able to connect wireless-ly through a local network to an Arduino YUN, get its components list.

For example :

"A LED is connected on ports :

Input : 2,

Output : 6;

and is currently on"

And change the input value :

"turn the LED off"

I'm not supposed to reload the webpage to see the change occurring. So I figured out I needed NodeJS to send/receive the informations with websockets but I don't know how to connect NodeJS -running on its own webserver- to cakephp. I'm a complete rookie with NodeJS, just did a few tutorials earlier, so I'm stuck here.

Does anyone know how to deal with this ?

Thanks in advance,

Was it helpful?

Solution

There are a few different libraries you can use to connect to the node server.

http://elephant.io/

https://github.com/bergie/dnode-php

You can, of course, just fall back to sending http requests (curl) from your cakephp app to the node server.

OTHER TIPS

I have a few discoveries to add that may help some people. While searching more deeply on DNode and elephant.io I found a cakePHP plugin called cake_websocket which make use of socket.io. Seems to me that it is an equivalent to elephant.io specialized in cakePHP (while elephant.io is 'just' PHP).

I hope it can help someone !

Instead of using any library.

You can try iframe tag with src to your 'node.js' view.html.

So, listen for events on view.html which are triggered from your 'cakephp' view.html

So, you will have cakephp->view.html talking to node.js->view.html which is connected to node.js->index.js(server)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top