lib/artoo/commands/connect.rb in artoo-1.0.0.rc3 vs lib/artoo/commands/connect.rb in artoo-1.0.0.rc4
- old
+ new
@@ -6,14 +6,21 @@
class Connect < Thor
include Thor::Actions
include Artoo::Utility
desc "scan", "scan for connected devices"
+ option :type, :default => "bluetooth", :desc => "type of scan [bluetooth, serial]"
def scan
case os
when :linux
- run("hcitool scan")
+ if options[:type] == 'bluetooth'
+ run("hcitool scan")
+ elsif options[:type] == 'serial'
+ run("ls /dev/tty.*")
+ else
+ say "ERROR: scan type '#{options[:type]}' not supported!"
+ end
when :macosx
run("ls /dev/tty.*")
else
say "OS not yet supported..."
end
@@ -23,10 +30,10 @@
option :comm, :default => 0, :desc => "Comm number"
option :radio, :default => "hci0", :desc => "Bluetooth radio address"
def bind(address, name)
case os
when :linux
- run("rfcomm -i #{options[:radio]} bind /dev/rfcomm#{options[:comm]} #{address} 1")
+ run("sudo rfcomm -i #{options[:radio]} bind /dev/rfcomm#{options[:comm]} #{address} 1")
run("sudo ln -s /dev/rfcomm#{options[:comm]} /dev/#{name}")
when :macosx
say "OSX binds devices on its own volition."
else
say "OS not yet supported..."