Merge pull request #103 from hybridgroup/bluetooth-scan-cmd

Added new 'cylon bluetooth scan' command.
This commit is contained in:
Adrian Zankich 2014-02-14 14:58:58 -08:00
commit 387aaa618c
5 changed files with 22 additions and 7 deletions

View File

@ -22,8 +22,8 @@ Program
});
Program
.command("bluetooth <subcmd> <address> [option]")
.description("Connect bluetooth device to PC (pairs) or establishes serial to bluetooth connection")
.command("bluetooth <subcmd> [address] [option]")
.description("Scan, pair, unpair bluetooth devices to/from the PC, establishes serial to bluetooth connection. Try 'cylon bluetooth help'")
.action(function(subcmd, address, option){
switch(subcmd){
case 'pair':
@ -38,11 +38,15 @@ Program
option = (option === null || option === undefined) ? '/dev/rfcomm0' : option;
CliCommands.connectToSerial(option, address);
break;
case 'scan':
CliCommands.bluetooth.scan();
break;
default:
console.log("cylon bluetooth argument not recognized, try:\n");
console.log("1.- cylon bluetooth pair <address> [hciX]");
console.log("2.- cylon bluetooth unpair <address> [hciX]");
console.log("3.- cylon bluetooth connect <address> [dev]\n");
console.log("1.- cylon bluetooth scan");
console.log("2.- cylon bluetooth pair <address> [hciX]");
console.log("3.- cylon bluetooth unpair <address> [hciX]");
console.log("4.- cylon bluetooth connect <address> [dev]\n");
}
});

View File

@ -1,8 +1,10 @@
(function() {
var bluetooth, os;
var bluetooth, os, scan;
require("./process");
scan = require("./scan");
os = require('os');
bluetooth = {
@ -31,6 +33,9 @@
default:
return console.log("OS not yet supported.");
}
},
scan: function() {
return scan('bluetooth');
}
};

View File

@ -12,7 +12,8 @@
connectToSerial: connectToSerial,
bluetooth: {
pair: bluetooth.pair,
unpair: bluetooth.unpair
unpair: bluetooth.unpair,
scan: bluetooth.scan
}
};

View File

@ -1,4 +1,5 @@
require "./process"
scan = require "./scan"
os = require('os')
bluetooth =
@ -30,4 +31,7 @@ bluetooth =
else
console.log "OS not yet supported."
scan: () ->
scan('bluetooth')
module.exports = bluetooth

View File

@ -8,5 +8,6 @@ cliCommands =
bluetooth:
pair: bluetooth.pair
unpair: bluetooth.unpair
scan: bluetooth.scan
module.exports = cliCommands