Class: Artoo::Commands::Bluetooth
Instance Method Summary
collapse
Methods inherited from Commands
banner, install_dir, install_path
Methods included from Utility
#classify, #constantize, #current_class, #current_instance, #os, #random_string, #underscore
Instance Method Details
#bind(address, name) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/artoo/commands/bluetooth.rb', line 17
def bind(address, name)
case os
when :linux
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..."
end
end
|
#connect(name, port) ⇒ Object
45
46
47
|
# File 'lib/artoo/commands/bluetooth.rb', line 45
def connect(name, port)
Artoo::Commands::Socket.new().connect(name, port, options[:retries], options[:baudrate])
end
|
#pair(address) ⇒ Object
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/artoo/commands/bluetooth.rb', line 50
def pair(address)
case os
when :linux
run("bluez-simple-agent hci0 #{ address }")
when :macosx
say "OS X manages Bluetooth pairing itself."
else
say "OS not yet supported..."
end
end
|
#unbind(address, name) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/artoo/commands/bluetooth.rb', line 30
def unbind(address, name)
case os
when :linux
run("sudo rfcomm unbind #{address}")
run("sudo rm /dev/#{name}")
when :macosx
say "OSX binds devices on its own volition."
else
say "OS not yet supported..."
end
end
|
#unpair(address) ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/artoo/commands/bluetooth.rb', line 62
def unpair(address)
case os
when :linux
run("bluez-simple-agent hci0 #{ address } remove")
when :macosx
say "OS X manages Bluetooth unpairing itself."
else
say "OS not yet supported..."
end
end
|