Latest cylon example updates
This commit is contained in:
parent
cb2ef05201
commit
027a82c17e
|
@ -6,7 +6,7 @@ faye = require('faye')
|
|||
|
||||
namespace = require('node-namespace')
|
||||
|
||||
namespace 'Cylon.SF', ->
|
||||
namespace 'SF', ->
|
||||
class @SFClient
|
||||
constructor: (opts) ->
|
||||
@client = null
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
require '../examples/sf-client'
|
||||
Cylon = require('..')
|
||||
|
||||
class SalesForceRobot
|
||||
|
||||
Cylon.robot
|
||||
connection:
|
||||
name: 'sphero', adaptor: 'sphero', port: '/dev/rfcomm0'
|
||||
|
||||
|
@ -10,7 +9,7 @@ class SalesForceRobot
|
|||
name: 'sphero', driver: 'sphero'
|
||||
|
||||
setupSF: ->
|
||||
new Cylon.SF.SFClient(sfuser: sfuser, sfpass: sfpass, orgCredentials: orgCreds)
|
||||
new SF.SFClient(this.sfCreds)
|
||||
|
||||
sfCreds:
|
||||
{
|
||||
|
@ -24,37 +23,29 @@ class SalesForceRobot
|
|||
}
|
||||
|
||||
work: (me) ->
|
||||
color = 0x00FF00
|
||||
bitFilter = 0xFFFF00
|
||||
|
||||
me.sf = me.setupSF()
|
||||
|
||||
mw.sf.authenticate((msg) =>
|
||||
@spheroRoll(0x00FF00)
|
||||
)
|
||||
|
||||
me.sphero.on('connect', ->
|
||||
Logger.info('Setting up Collision Detection...')
|
||||
me.sphero.detectCollisions()
|
||||
me.sphero.stop()
|
||||
@spheroRoll(0x00FF00)
|
||||
me.sphero.setRGB(0x00FF00)
|
||||
me.sphero.roll 90, Math.floor(Math.random() * 360)
|
||||
)
|
||||
|
||||
me.sphero.on 'collision', (data) ->
|
||||
Logger.info 'collision:'
|
||||
me.sphero.setRGB(0xFF0000)
|
||||
me.sphero.setRGB(0xFF0000, me)
|
||||
me.sphero.stop()
|
||||
console.log("Collision Data:")
|
||||
console.log(data)
|
||||
toSend = "{ \"identifier\" :\"#{ me.name }\", \"msg\": \"#{ data }\" }"
|
||||
@sf.psh(toSend)
|
||||
console.log(data[0][0])
|
||||
toSend = "{ \"identifier\" :\"#{ me.name }\", \"msg\": \"#{ 'hello' }\" }"
|
||||
me.sf.push(toSend)
|
||||
|
||||
spheroRoll: (color) ->
|
||||
me.sphero.setRGB(color)
|
||||
me.sf.authenticate((msg) =>
|
||||
Logger.info 'SF Outbound Msg:'
|
||||
me.sphero.setRGB(0x00FF00)
|
||||
me.sphero.roll 90, Math.floor(Math.random() * 360)
|
||||
)
|
||||
|
||||
robot = new SalesForceRobot
|
||||
|
||||
Cylon.robot robot
|
||||
|
||||
Cylon.start()
|
||||
.start()
|
||||
|
|
Loading…
Reference in New Issue