Module: SonyCameraRemoteAPI::Scripts
- Included in:
- Client::Config, Client::Main
- Defined in:
- lib/sony_camera_remote_api/scripts.rb
Overview
Helper module for connecting to camera by wi-fi.
Class Method Summary collapse
-
.connect(interface, ssid, pass) ⇒ Boolean
Connects to camera by Wi-Fi.
-
.connection_script ⇒ Object
Full path of connection script.
-
.path ⇒ Object
Path where scripts are located.
-
.restart_and_connect(interface, ssid, pass) ⇒ Boolean
Restart the interface and connect to camera by Wi-Fi.
-
.root ⇒ Object
Get gem root path (not smart).
-
.run_external_command(command) ⇒ Boolean
Run shell command.
Class Method Details
.connect(interface, ssid, pass) ⇒ Boolean
Connects to camera by Wi-Fi. This method does nothing if already connected, which is judged by ifconfig command.
15 16 17 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 15 def connect(interface, ssid, pass) run_external_command "sudo bash #{connection_script} #{interface} #{ssid} #{pass}" end |
.connection_script ⇒ Object
Full path of connection script
59 60 61 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 59 def connection_script File.join path, 'connect.sh' end |
.path ⇒ Object
Path where scripts are located
54 55 56 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 54 def path File.join root, 'scripts' end |
.restart_and_connect(interface, ssid, pass) ⇒ Boolean
Restart the interface and connect to camera by Wi-Fi.
24 25 26 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 24 def restart_and_connect(interface, ssid, pass) run_external_command "sudo bash #{connection_script} -r #{interface} #{ssid} #{pass}" end |
.root ⇒ Object
Get gem root path (not smart)
49 50 51 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 49 def root File. '../../..', __FILE__ end |
.run_external_command(command) ⇒ Boolean
Run shell command. Command output are written to stdout witout buffering.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 33 def run_external_command(command) puts command Open3.popen2e(command) do |_i, oe, w| oe.each do |line| puts line end # Return code if w.value != 0 return false else return true end end end |