Created
April 5, 2018 15:51
-
-
Save next-marianmoldovan/b11e935e9a094e388b97edc86c480fff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.address = function(){ | |
var bb8Addres = 'ef:50:05:54:ea:7c'; | |
// Becasue MacOs needs uuid not physical adress | |
if(process.platform === 'darwin') | |
bb8Addres = 'a025abc966a04dd98b9f3d465c84d918'; | |
return bb8Addres; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var sphero = require('sphero'); | |
var bb8Config = require('./bb8Config.js'); | |
var bb8 = sphero(bb8Config.address()); | |
// Connect to our BB8 | |
bb8.connect(start); | |
// When connection is succesful, sync if needed | |
function start() { | |
bb8.getPowerState(function(err, data) { | |
if (err) { | |
console.log("error: ", err); | |
} else { | |
console.info(" batteryVoltage:", data.batteryVoltage); | |
} | |
}); | |
// Avoid sleep | |
setInterval(function(){ | |
bb8.ping(); | |
}, 30000); | |
} | |
// Set Color of BB8, list of rgb from https://github.com/orbotix/sphero.js/blob/05e267ae9ed0608f221298454f82a7404fc58237/lib/colors.js | |
function setColor(color) { | |
bb8.color(color, 1); | |
} | |
// Set Blue back led, values from 0 to 255 | |
function setBackLed(color) { | |
bb8.setBackLed(color); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "t3cfest", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"prestart": "sudo hciconfig hci0 up" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "git+https://github.com/beeva-marianmoldovan/resin-sense.git" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"log-util": "^1.1.1", | |
"noble": "^1.9.1", | |
"node-blink1": "^0.2.2", | |
"sphero": "^0.9.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment