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

View File

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

View File

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

View File

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

View File

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