Module: SonyCameraRemoteAPI::Scripts
- Included in:
- Client::Main, Client::ShelfCmd
- Defined in:
- lib/sony_camera_remote_api/scripts.rb
Overview
Helper module for connecting to camera by wi-fi.
Class Method Summary collapse
-
.connect(ssid, pass, interface) ⇒ 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(ssid, pass, interface) ⇒ 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(ssid, pass, interface) ⇒ 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(ssid, pass, interface) run_external_command "sudo bash #{connection_script} #{ssid} #{pass} #{interface}" end |
.connection_script ⇒ Object
Full path of connection script
60 61 62 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 60 def connection_script File.join path, 'connect.sh' end |
.path ⇒ Object
Path where scripts are located
55 56 57 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 55 def path File.join root, 'scripts' end |
.restart_and_connect(ssid, pass, interface) ⇒ Boolean
Restart the interface and connect to camera by Wi-Fi.
25 26 27 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 25 def restart_and_connect(ssid, pass, interface) run_external_command "sudo bash #{connection_script} -r #{ssid} #{pass} #{interface}" end |
.root ⇒ Object
Get gem root path (not smart)
50 51 52 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 50 def root File. '../../..', __FILE__ end |
.run_external_command(command) ⇒ Boolean
Run shell command. Command output are written to stdout witout buffering.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sony_camera_remote_api/scripts.rb', line 34 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 |