Skip to content

Instantly share code, notes, and snippets.

@next-marianmoldovan
Created April 5, 2018 15:51
Show Gist options
  • Save next-marianmoldovan/b11e935e9a094e388b97edc86c480fff to your computer and use it in GitHub Desktop.
Save next-marianmoldovan/b11e935e9a094e388b97edc86c480fff to your computer and use it in GitHub Desktop.
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;
}
'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);
}
{
"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