2014-02-02 06:42:32 +08:00
|
|
|
(function() {
|
|
|
|
var connectToSerial, os;
|
|
|
|
|
2014-02-05 03:31:17 +08:00
|
|
|
require("./process");
|
2014-02-02 06:42:32 +08:00
|
|
|
|
|
|
|
os = require('os');
|
|
|
|
|
|
|
|
connectToSerial = function(dev, 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('sudo', ['rfcomm', 'connect', dev, address, '1']);
|
2014-02-02 06:42:32 +08:00
|
|
|
case 'darwin':
|
2014-02-05 05:38:29 +08:00
|
|
|
return console.log("OS X manages binding 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 = connectToSerial;
|
|
|
|
|
|
|
|
}).call(this);
|