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