cylon/dist/cli/bluetooth.js

40 lines
1.0 KiB
JavaScript
Raw Normal View History

(function() {
var bluetooth, os;
require("./process");
os = require('os');
bluetooth = {
pair: function(hciX, address) {
2014-02-05 05:38:29 +08:00
var platform, process;
process = new Cylon.Process;
platform = os.platform();
switch (platform) {
case 'linux':
2014-02-05 05:38:29 +08:00
return process.spawn('bluez-simple-agent', [hciX, address]);
case 'darwin':
2014-02-05 05:38:29 +08:00
return console.log("OS X manages Bluetooth pairing itself.");
default:
2014-02-05 05:38:29 +08:00
return console.log("OS not yet supported.");
}
},
unpair: function(hciX, address) {
2014-02-05 05:38:29 +08:00
var platform, process;
process = new Cylon.Process;
platform = os.platform();
switch (platform) {
case 'linux':
2014-02-05 05:38:29 +08:00
return process.spawn('bluez-simple-agent', [hciX, address, 'remove']);
case 'darwin':
2014-02-05 05:38:29 +08:00
return console.log("OS X manages Bluetooth unpairing itself.");
default:
2014-02-05 05:38:29 +08:00
return console.log("OS not yet supported.");
}
}
};
module.exports = bluetooth;
}).call(this);