- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I have been able to make my intel galileo serve as a webserver, and i can connect to a web app on intel galileo through wifi from phone or laptop. But how do I send and receive data from intel Galileo? For example: If I clicked the turn on or turn off button on the web app, how do I make this instruction active on galileo?
I have tried searching the internet for solution but only came across "ConnectAnyThing", but I don't see how I can add my own web pages and also write Node.js in my Intel XDK IOT if I used "ConnectAnyThing".
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
You need to spawn a process probably (https://nodejs.org/api/child_process.html# child_process_example_sending_server_object Child Process Node.js v4.2.1 Manual & Documentation)
The example that the URL jumps to should work fine though (note version 4 though)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Pasting the code here for convenience:
var spawn = require('child_process').spawn, ls = spawn('ls', ['-lh', '/usr']); ls.stdout.on('data', function (data) { console.log('stdout: ' + data); }); ls.stderr.on('data', function (data) { console.log('stderr: ' + data); }); ls.on('close', function (code) { console.log('child process exited with code ' + code); });
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thanks a lot.
But, please how do i use this code, where do i pass the button handle and the function it should execute, when the button is clicked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Can you be a little more specific? spawning will let you execute OS commands in node, receive their return values etc. You should look into the sample provided https://software.intel.com/en-us/getting-started-with-the-intel-xdk-iot-edition IoT - Getting started with the Intel® XDK IoT Edition | Intel® Developer Zone
The ToggleLED project performs a hardware action when a button is pressed in the browser.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi PETRONG,
I would like to know if you have been able to run the code provided for Taimoor. Also, did you check the ToggleLED project?
Regards,
Charlie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
This is a snapshot from a web app, When that pink switch on the right hand side of the image is clicked, its label changes to either "on" or "off". I want to be able to use that pink switch to either turn on or turn off the led.
I thought i could do something like; "if the label says 'off' then set led state as 0, else set led state as 1".
I tried to use something like "document.querySelector(".switchLabel").innerHTML" to get the value of the switch label in intel XDK IOT main.js file, but it gave an error instead, saying that "document" is undefined.
I suppose I must use node.js to do this, but I have no clues
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi PETRONG,
I suggest you to take a look at the examples in the XDK: Web Sockets and Simple Web Server. There is another thread with a similar application: that may help you but is with Python
Regards,
Charlie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I loaded the websockets template in Intel XDK IOT, but it gave errors signifying that I needed to install the socket.io module. I run this: "root@galileo:~# npm install socket.io" and it gives me the error below on the console. Please any way out?
Thanks.
npm ERR! network tunneling socket could not be established, cause=getaddrinfo ENOTFOUND
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! System Linux 3.8.7-yocto-standard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
...one more question please: When I am completely done with my galileo project how do upload it to the galileo so that i dont have to turn on intel XDK IOT to use it. I want to be able to connect to galileo with my phone without having to connect the galileo board to a pc on the same network, since my galileo is the webserver. How do I achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Normally, you shouldn't need to do anything if you started afresh. The XDK daemon should already start your project with a reboot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi PETRONG,
What is the output of running in your board the following commands?
uname -a
npm --version
node --version
Are you able to see this folder: /opt/xdk-daemon/current/node-inspector-server/node_modules/v8-debug/build/Release/.deps/home/pokybuild/yocto-autobuilder/yocto-worker/quark-multilib/build/build/tmp/work/i586-poky-linux/xdk-daemon/0.0.37-r0/
Which XDK version are you using?
Regarding your question: how do upload it to the galileo so that i dont have to turn on intel XDK IOT to use it. You have access to the main.js in /node_app_slot, you can run the script in there with node main.js
Regards,
Charlie

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page