Skip to content

Instantly share code, notes, and snippets.

@redaphid
Created August 31, 2014 18:31
Show Gist options
  • Save redaphid/58dae0e6de63534b95c7 to your computer and use it in GitHub Desktop.
Save redaphid/58dae0e6de63534b95c7 to your computer and use it in GitHub Desktop.
Pebble watch to meshblu proxy
var express = require('express'),
app = express(),
skynet = require('skynet');
var conn = skynet.createConnection({
server: 'http://skynet.im',
port: 80,
uuid: '1f1200c1-2b02-11e4-9001-b7f689b1ce71',
token: '2pe8dz4uuh6ez5mirkhi857ohxrjxlxr'
});
conn.on('ready', function(){
console.log('Im ready');
app.get('/lock', function (req, res) {
console.log('someone tried to lock');
sendSkynetMessage('lock');
res.send('lock');
});
app.get('/unlock', function (req, res) {
console.log('someone tried to unlock');
sendSkynetMessage('unlock');
res.send('unlock');
});
app.get('/lights', function (req, res) {
console.log('someone tried to lights');
sendSkynetMessage('lights');
res.send('lights');
});
app.get('/lightsoff', function (req, res) {
console.log('someone tried to lights');
sendSkynetMessage('lightsoff');
res.send('lightsoff');
});
app.get('/wipe', function (req, res) {
console.log('someone tried to wipe');
sendSkynetMessage('wipe');
res.send('wipe');
});
var server = app.listen(3000, function () {
console.log('Listening on port %d', server.address().port);
});
// skynetConnection.message(options, function (result) {
// console.log('meshblu response:', result);
// defer.resolve(result);
// });
});
function sendSkynetMessage(message) {
conn.message({devices: '*', payload: {message: message}});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment