Add skynet examples
This commit is contained in:
parent
e2fa83196d
commit
277643bded
|
@ -0,0 +1,24 @@
|
|||
Cylon = require '../..'
|
||||
|
||||
Cylon.robot
|
||||
connections: [
|
||||
{ name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
|
||||
# { name: 'skynet', adaptor: 'skynet', uuid: "742401f1-87a4-11e3-834d-670dadc0ddbf", token: "xjq9h3yzhemf5hfrme8y08fh0sm50zfr" }
|
||||
{ name: 'skynet', adaptor: 'skynet', host: 'localhost', portNumber: 3000, uuid: "18676eb1-9997-11e3-8c2a-f18a07a72684", token: "vbeo289aik65hfr1lns8vst273nmi" }
|
||||
]
|
||||
|
||||
device: { name: 'led', driver: 'led', pin: 13, connection: 'arduino' }
|
||||
|
||||
work: (my) ->
|
||||
Logger.info "connected..."
|
||||
my.connections['skynet'].on 'message', (channel, data) ->
|
||||
console.log(data)
|
||||
data = JSON.parse(data)
|
||||
if data.red is 'on'
|
||||
console.log("red on request received from skynet");
|
||||
my.led.turnOn()
|
||||
else if data.red is 'off'
|
||||
console.log("red off request received from skynet");
|
||||
my.led.turnOff()
|
||||
|
||||
.start()
|
|
@ -0,0 +1,24 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.robot({
|
||||
connections: [
|
||||
{ name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
|
||||
{ name: 'skynet', adaptor: 'skynet', uuid: "742401f1-87a4-11e3-834d-670dadc0ddbf", token: "xjq9h3yzhemf5hfrme8y08fh0sm50zfr" }
|
||||
],
|
||||
|
||||
device: { name: 'led', driver: 'led', pin: 13, connection: 'arduino' },
|
||||
|
||||
work: function(my) {
|
||||
Logger.info("connected...");
|
||||
my.skynet.on('message', function(channel, data) {
|
||||
Logger.info(data);
|
||||
var data = JSON.parse(data);
|
||||
if(data.red == 'on') {
|
||||
my.led.turnOn()
|
||||
}
|
||||
else if(data.red == 'off') {
|
||||
my.led.turnOff()
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
Loading…
Reference in New Issue