A unified IO Javascript library for IOT device(Galileo/Edison), companion device(phone/tablet) and XDK.
- Arduino like API
- Unified API for nodejs and browser
- Standard JSON-RPC 2.0 support
- Offload execution
- Autogen tools for customized IO functions
- This library can run correctly both on Intel dev kit https://software.intel.com/en-us/iotdevkit which contains host a machine running DevKit Live USB image and target Intel Galileo platform. This IO library can run on both of them. Below is a quick guide of how to enable nodejs on host and target.
-
Uncompress image & recover image to micro sd card with
dd
cmd
dd if=/path/to/image of=/sd/dev/path bs=1M
-
insert SD card to galileo, then power on galileo
-
ssh login
ssh root@ip_address_for_galileo
- check node/node-gyp/npm
- If not in $PATH, please find it under root directory, then create symbol link for it. for example,
ln -s /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js /usr/bin/node-gyp
-
Make sure Galileo system is set correctly.
-
copy io-js to galileo, then you can jump to
Installation
section. But the installation is very slow on Galileo. You may want to compile the library on host machine with cross compiler
-
Download iot dev kit image (4.2G)
-
Although devkit officially suggest to use it as bootable USB key, but we suggest you to boot it in virtual machine.
-
Download & Install Virtual box
-
uncompress image & convert image to virtual box image
vboxmanage convertfromraw --format VMDK devkit-live-img-final.binblob ~/devkit.vmdk
-
Boot up devkit.vmdk in virtual box
-
login virtual machine
-
check node/node-gyp/npm
- If not under $PATH, please find it under root directory, then create symbol link for it. for example,
ln -s /opt/iot-devkit/1.5.1/yocto/sysroots/i586-poky-linux/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js /usr/bin/node-gyp
- copy io-js to devkit, then run it followed
Installation
part.
npm install
(if run io-js
as root, please use "npm install -unsafe-perm" instead)
- Native IO operation on IOT device
var IOLIB = (typeof require === 'function') ? require('../'): this.IOLIB;
var io = new IOLIB.IO({
log: true
});
var led = new IOLIB.Led({
io: io,
pin: 13
});
led.blink();
- RPC client which submits the IO request to IOT device.
Only needs to add RPC options to IO constructor. The code works in nodejs or browser.
var io = new IOLIB.IO({
log: true,
rpc: true,
port: 2000,
hostname: 'localhost',
});
- Offload execution
The client can offload functions to remote server.
var IOLIB = (typeof require === 'function') ? require('..'): this.IOLIB;
var io = new IOLIB.IO({
log: true,
rpc: true,
port: 2000,
hostname: 'localhost',
});
io.offload(function(IOLIB, context) {
var io = new IOLIB.IO({
emu: true,
log: true
});
var led = new IOLIB.Led({
io: io,
pin: 13
});
led.off();
context.save = 1;
return true;
});
io.offloadQuery(function(error, response) {
console.log(JSON.stringify(response));
});
We choose Buster.js to run tests in Nodejs and browser
Install buster.js
npm install -g buster
Run test
make test
Go to target/device/libio