sony_camera_remote_api 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1673c9a0e55968b5691e720ba4580f10fdc89301
4
- data.tar.gz: b7dfb169b64c3625e80d5a480a8d50d3aa6a5af2
3
+ metadata.gz: b09ff475a257587236804069142d110d0176e751
4
+ data.tar.gz: 8bedc578a1e42c47cd9ef6deaf708cad2affaa03
5
5
  SHA512:
6
- metadata.gz: 41eef398296c1351f7c792c9ca67c38a7102f831790f97d381e8db2ce15deb252b9b335de830f91c3d922c54822120b56fad94868afff9b62765eac6a42a1107
7
- data.tar.gz: 90bb27d0d5cad30a6d3999f640efa1caf4f47fc4f96a5c105cf35b363687ba844962b805765b5dceb74e07167690b0a22271f318e10590e6326f69ad7837b942
6
+ metadata.gz: 8af7fd14d9a3c3805ee56821f655c21f4bb06b58fc4735d9b69fcdbff2f7cc825c8028e19c238800c3fa29a69321fc8b46a77d2fb48a23be5560727c2e6bccc7
7
+ data.tar.gz: b80072cf80afade4af08a6dfc49e6496762d8efe3370f54f7ad40ae47ecc5196544322df497a87e81b65bc5b9303b910f2f1566bd622ad8f3ee0abaaad7a2ff0
data/README.md CHANGED
@@ -1,98 +1,101 @@
1
- # Sony Remote Camera API Wrapper
2
-
3
- A Ruby Gem that facilitates the use of Sony Remote Camera API.
4
-
5
- - [Backgrounds](#backgrounds)
6
- - [Features](#features)
7
- - [Supported version](#supported-version)
8
- - [Installation](#installation)
9
- - [Usage](#usage)
10
- - [Development](#development)
11
- - [Contributing](#contributing)
12
- - [License](#license)
13
-
14
-
15
- ## Backgrounds
16
-
17
- [Sony Camera Remote API](https://developer.sony.com/develop/cameras/) allows us to control a number of Sony cameras, including Sony Action cams, Sony Alpha cameras and Lens Style cameras, wirelessly from another device.
18
- But these APIs are quite low-level, so that we have to implement a lot of sequences while considering many pitfalls, which are less documented in their API reference.
19
- This gem is a wrapper library that make it easy to use Sony camera functions for high-level applications.
20
-
21
-
22
- ## Features
23
-
24
- * Streaming live-view images by one method
25
- * Simplified contents transfer
26
- * Consistent interface for changing parameters safely
27
- * Auto reconnection
28
- * Also supports the low-level APIs call
29
- * Client application bundled
30
-
31
-
32
- ## Supported version
33
-
34
- Ruby 2.0 or higher
35
-
36
- ## Installation
37
-
38
- Add this line to your application's Gemfile:
39
-
40
- ```ruby
41
- gem 'sony_camera_remote_api'
42
- ```
43
-
44
- And then execute:
45
-
46
- $ bundle
47
-
48
- Or install it yourself as:
49
-
50
- $ gem install sony_camera_remote_api
51
-
52
-
53
- ## Usage
54
-
55
- 1. Connect your PC to the camera by Direct Wi-Fi. If you are using Linux, bundled scripts and its interface method are available.
56
- 2. Create SonyCameraRemoteAPI::Camera object. It takes a little time because of SSDP search.
57
- 3. Now you can call not only wrapper methods but also original APIs as a method!
58
-
59
- If you want to take a picture and save it:
60
-
61
- ```ruby
62
- require 'sony_camera_remote_api'
63
- require 'sony_camera_remote_api/scripts'
64
-
65
- interface = "wlan0"
66
- ssid = "DIRECT-xxxx:ILCE-QX1"
67
- pass = "xxxxxxxx"
68
-
69
- SonyCameraRemoteAPI::Scripts.connect interface, ssid, pass
70
- cam = SonyCameraRemoteAPI::Camera.new
71
- cam.change_function_to_shoot 'still', 'Single'
72
- cam.capture_still
73
- # => Captured jpeg file is transferred to your PC
74
- ```
75
-
76
- For more information, see [Wiki](https://github.com/kota65535/sony_camera_remote_api/wiki).
77
-
78
-
79
- ## TODO
80
-
81
- * Remote playback function
82
-
83
-
84
- ## Development
85
-
86
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
87
-
88
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
89
-
90
-
91
- ## Contributing
92
-
93
- Bug reports and pull requests are welcome on GitHub at https://github.com/kota65535/sony_camera_remote_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
94
-
95
-
96
- ## License
97
-
98
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
1
+ # Sony Remote Camera API Wrapper
2
+
3
+ A Ruby Gem that facilitates the use of Sony Remote Camera API.
4
+
5
+ - [Backgrounds](#backgrounds)
6
+ - [Features](#features)
7
+ - [Supported version](#supported-version)
8
+ - [Installation](#installation)
9
+ - [Usage](#usage)
10
+ - [Development](#development)
11
+ - [Contributing](#contributing)
12
+ - [License](#license)
13
+
14
+
15
+ ## Backgrounds
16
+
17
+ [Sony Camera Remote API](https://developer.sony.com/develop/cameras/) allows us to control a number of Sony cameras, including Sony Action cams, Sony Alpha cameras and Lens Style cameras, wirelessly from another device.
18
+ But these APIs are quite low-level, so that we have to implement a lot of sequences while considering many pitfalls, which are less documented in their API reference.
19
+ This gem is a wrapper library that make it easy to use Sony camera functions for high-level applications.
20
+
21
+
22
+ ## Features
23
+
24
+ * Streaming live-view images by one method
25
+ * Simplified contents transfer
26
+ * Consistent interface for changing parameters safely
27
+ * Auto reconnection
28
+ * Also supports the low-level APIs call
29
+ * Client application bundled
30
+
31
+
32
+ ## Supported version
33
+
34
+ Ruby 2.0 or higher
35
+
36
+ ## Installation
37
+
38
+ Add this line to your application's Gemfile:
39
+
40
+ ```ruby
41
+ gem 'sony_camera_remote_api'
42
+ ```
43
+
44
+ And then execute:
45
+
46
+ $ bundle
47
+
48
+ Or install it yourself as:
49
+
50
+ $ gem install sony_camera_remote_api
51
+
52
+
53
+ ## Usage
54
+
55
+ 1. Connect your PC (or device) to the camera with Direct Wi-Fi. If you are using Linux, it is recommended to use
56
+ Shelf class like the following example.
57
+ 2. Create SonyCameraRemoteAPI::Camera instance with Shelf instance.
58
+ 3. Now you can access all of camera APIs and useful wrapper methods!
59
+
60
+ This is an example code of capturing single still image.
61
+
62
+ ```ruby
63
+ require 'sony_camera_remote_api'
64
+
65
+ interface = "wlan0"
66
+ ssid = "DIRECT-xxxx:ILCE-QX1"
67
+ pass = "xxxxxxxx"
68
+
69
+ shelf = SonyCameraRemoteAPI::Shelf.new 'sonycam.shelf'
70
+ shelf.add_and_select ssid, pass, interface
71
+ shelf.connect
72
+
73
+ cam = SonyCameraRemoteAPI::Camera.new shelf
74
+ cam.change_function_to_shoot 'still', 'Single'
75
+ cam.capture_still
76
+ # => Captured jpeg file is transferred to your PC
77
+ ```
78
+
79
+ For more information, see project's [Wiki](https://github.com/kota65535/sony_camera_remote_api/wiki).
80
+
81
+
82
+ ## TODO
83
+
84
+ * Remote playback function
85
+
86
+
87
+ ## Development
88
+
89
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
90
+
91
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
92
+
93
+
94
+ ## Contributing
95
+
96
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kota65535/sony_camera_remote_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
97
+
98
+
99
+ ## License
100
+
101
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -38,16 +38,24 @@ module SonyCameraRemoteAPI
38
38
 
39
39
  # Creates a new Camera object.
40
40
  # @note It is good idea to save endpoint URLs by each cameras somewhere to omit SSDP search.
41
- # @param [Hash] endpoints Endpoint URLs. if not given, SSDP search is executed.
42
- # @param [Proc] reconnect_by Hook method called when Wi-Fi is disconnected.
43
- # @param [String, IO, Array<String, IO>] log_file file name or stream to output log.
44
- # @param [Boolean] finalize If true, stopRecMode API is called in the destructor.
45
- # As far as I know, we don't have any trouble even if we never call stopRecMode.
46
- def initialize(endpoints: nil, reconnect_by: nil, log_file: $stdout, log_level: Logger::INFO, finalize: false)
41
+ # @param [Shelf] shelf Shelf class object that is used for connection.
42
+ # @param [Proc] reconnect_by Hook method to reconnect to the camera, which is called when Wi-Fi is disconnected.
43
+ # Not necessary if +shelf+ is given.
44
+ # @param [String, IO, Array<String, IO>] log_file File name or stream to output log.
45
+ # @param [Boolean] finalize If +true+, stopRecMode API is called in the destructor.
46
+ # As far as I know, we have no problem even if we never call stopRecMode.
47
+ def initialize(shelf = nil, reconnect_by: nil, log_file: $stdout, log_level: Logger::INFO, finalize: false)
47
48
  set_output log_file
48
49
  set_level log_level
49
- @endpoints = endpoints || ssdp_search
50
- @reconnect_by = reconnect_by
50
+ if shelf
51
+ @endpoints = shelf.ep || ssdp_search
52
+ shelf.set_ep @endpoints
53
+ @reconnect_by = shelf.method(:reconnect)
54
+ else
55
+ @endpoints = ssdp_search
56
+ end
57
+ @reconnect_by = reconnect_by if reconnect_by
58
+
51
59
  @api_manager = CameraAPIManager.new @endpoints, reconnect_by: @reconnect_by
52
60
  @cli = HTTPClient.new
53
61
  @cli.connect_timeout = @cli.send_timeout = @cli.receive_timeout = 30
@@ -62,7 +70,8 @@ module SonyCameraRemoteAPI
62
70
  end
63
71
  end
64
72
 
65
- # Destructor
73
+
74
+ # Destructor: this calls stopRecMode API to finish shooting.
66
75
  def self.finalize(this)
67
76
  proc do
68
77
  this.stopRecMode!
@@ -73,10 +82,11 @@ module SonyCameraRemoteAPI
73
82
 
74
83
  # Change camera function to 'Remote Shooting' and then set shooting mode.
75
84
  # @param [String] mode Shoot mode
76
- # @param [String] cont Continous shooting mode (only available when shoot mode is 'still')
85
+ # @param [String] cont Continuous shooting mode (only available when shoot mode is 'still')
77
86
  # @return [void]
78
87
  # @see 'Shoot mode parameters' in API reference
79
88
  # @see 'Continuous shooting mode parameter' in API reference
89
+ # @todo make mode argument nullable
80
90
  def change_function_to_shoot(mode, cont = nil)
81
91
  # cameras that does not support CameraFunction API group has only 'Remote Shooting' function
82
92
  set_parameter! :CameraFunction, 'Remote Shooting'
@@ -107,14 +117,15 @@ module SonyCameraRemoteAPI
107
117
  # * MotionShot : take 10 pictures and render the movement into a single picture
108
118
  # @param [Boolean] transfer Flag to transfer the postview image.
109
119
  # @param [String] filename Name of image file to be transferred. If not given, original name is used.
110
- # Only available in Single/MotionShot shooting mode.
111
- # @param [String] prefix Prefix of sequencial image files to be transferred. If not given, original name is used.
112
- # Only available in Burst shooting mode.
120
+ # Only available in Single/MotionShot shooting mode.
121
+ # @param [String] prefix Prefix of sequential image files to be transferred. If not given, original name is used.
122
+ # Only available in Burst shooting mode.
113
123
  # @param [String] dir Directory where image file is saved. If not given, current directory is used.
114
124
  # @return [String, Array<String>, nil] Filename of the transferred image(s). If 'transfer' is false, returns nil.
115
125
  # @example
116
126
  # # Initialize
117
127
  # cam = SonyCameraRemoteAPI::Camera.new
128
+ #
118
129
  # # Capture a single still image, and then save it as images/TEST.JPG.
119
130
  # cam.change_function_to_shoot 'still', 'Single'
120
131
  # cam.capture_still filename: 'TEST.JPG', dir: 'images'
@@ -156,10 +167,11 @@ module SonyCameraRemoteAPI
156
167
  # @example
157
168
  # # Initialize
158
169
  # cam = SonyCameraRemoteAPI::Camera.new
170
+ # cam.change_function_to_shoot 'still', 'Continuous'
171
+ #
159
172
  # # Start continuous shooting and transfer all images.
160
- # cam.change_function_to_shoot('still', 'Continuous')
161
173
  # cam.start_continuous_shooting
162
- # ...
174
+ # sleep 5
163
175
  # cam.stop_continuous_shooting(transfer: true)
164
176
  def start_continuous_shooting
165
177
  wait_event { |r| r[1]['cameraStatus'] == 'IDLE' }
@@ -210,10 +222,11 @@ module SonyCameraRemoteAPI
210
222
  # @example
211
223
  # # Initialize
212
224
  # cam = SonyCameraRemoteAPI::Camera.new
213
- # # Record movie and transfer it.
214
225
  # cam.change_function_to_shoot('movie')
226
+ #
227
+ # # Record movie and transfer it.
215
228
  # cam.start_movie_recording
216
- # ...
229
+ # sleep 5
217
230
  # cam.stop_movie_recording(transfer: true)
218
231
  def start_movie_recording
219
232
  wait_event { |r| r[1]['cameraStatus'] == 'IDLE' }
@@ -246,10 +259,11 @@ module SonyCameraRemoteAPI
246
259
  # @example
247
260
  # # Initialize
248
261
  # cam = SonyCameraRemoteAPI::Camera.new
249
- # # Start interval still recording (does not transfer).
250
262
  # cam.change_function_to_shoot('intervalstill')
263
+ #
264
+ # # Start interval still recording (does not transfer).
251
265
  # cam.start_interval_recording
252
- # ...
266
+ # sleep 5
253
267
  # cam.stop_interval_recording
254
268
  def start_interval_recording
255
269
  wait_event { |r| r[1]['cameraStatus'] == 'IDLE' }
@@ -283,10 +297,11 @@ module SonyCameraRemoteAPI
283
297
  # @example
284
298
  # # Initialize
285
299
  # cam = SonyCameraRemoteAPI::Camera.new
286
- # # Start loop movie recording (does not transfer).
287
300
  # cam.change_function_to_shoot('looprec')
301
+ #
302
+ # # Start loop movie recording (does not transfer).
288
303
  # cam.start_loop_recording
289
- # ...
304
+ # sleep 5
290
305
  # cam.stop_loop_recording
291
306
  def start_loop_recording
292
307
  wait_event { |r| r[1]['cameraStatus'] == 'IDLE' }
@@ -312,7 +327,7 @@ module SonyCameraRemoteAPI
312
327
  end
313
328
 
314
329
 
315
- # Act zoom.
330
+ # Do zoom.
316
331
  # Zoom position can be specified by relative and absolute percentage within the range of 0-100.
317
332
  # If Both option are specified, absolute position is preceded.
318
333
  # @param [Fixnum] absolute Absolute position of the lense. 0 is the Wide-end and 100 is the Tele-end.
@@ -321,6 +336,7 @@ module SonyCameraRemoteAPI
321
336
  # @example
322
337
  # # Initialize
323
338
  # cam = SonyCameraRemoteAPI::Camera.new
339
+ #
324
340
  # cam.act_zoom(absolute: 0) # zoom out to the wide-end
325
341
  # cam.act_zoom(absolute: 100) # zoom in to the tele-end
326
342
  # cam.act_zoom(relative: -50) # zoom out by -50 from the current position
@@ -363,13 +379,14 @@ module SonyCameraRemoteAPI
363
379
 
364
380
 
365
381
  # Do focus, which is the same as half-pressing the shutter button.
382
+ # @note You have to set shooting mode to 'still' before calling this method.
366
383
  # @return [Boolean] +true+ if focus succeeded, +false+ if failed.
367
384
  # @example
368
385
  # # Initialize
369
386
  # cam = SonyCameraRemoteAPI::Camera.new
370
- # # Focus function is available only 'still' shoot mode
371
387
  # cam.change_function_to_shoot 'still'
372
- # # Capture forever only when focus succeeded.
388
+ #
389
+ # # Capture forever only when succeeded to focus.
373
390
  # loop do
374
391
  # if cam.act_focus
375
392
  # cam.capture_still
@@ -393,8 +410,9 @@ module SonyCameraRemoteAPI
393
410
 
394
411
 
395
412
  # Do touch focus, by which we can specify the focus position.
396
- # @note Tracking focus and Touch focus is exclusive function.
397
- # Tracking focus is disabled automatically by calling this method.
413
+ # @note You have to set shooting mode to 'still' before calling this method.
414
+ # @note Tracking focus and Touch focus are exclusive functions.
415
+ # So tracking focus is automatically disabled by calling this method.
398
416
  # @param [Fixnum] x Percentage of X-axis position.
399
417
  # @param [Fixnum] y Percentage of Y-axis position.
400
418
  # @return [Boolean] AFType ('Touch' or 'Wide') if focus succeeded. nil if failed.
@@ -402,6 +420,8 @@ module SonyCameraRemoteAPI
402
420
  # @example
403
421
  # # Initialize
404
422
  # cam = SonyCameraRemoteAPI::Camera.new
423
+ # cam.change_function_to_shoot 'still'
424
+ #
405
425
  # # Try to focus on upper-middle position.
406
426
  # if cam.act_touch_focus(50, 10)
407
427
  # cam.capture_still
@@ -427,6 +447,7 @@ module SonyCameraRemoteAPI
427
447
 
428
448
  # Do tracking focus, by which the focus position automatically track the object.
429
449
  # The focus position is expressed by percentage to the origin of coordinates, which is upper left of liveview images.
450
+ # @note You have to set shooting mode to 'still' before calling this method.
430
451
  # @param [Fixnum] x Percentage of X-axis position.
431
452
  # @param [Fixnum] y Percentage of Y-axis position.
432
453
  # @return [Boolean] +true+ if focus succeeded, +false+ if failed.
@@ -434,6 +455,7 @@ module SonyCameraRemoteAPI
434
455
  # # Initialize
435
456
  # cam = SonyCameraRemoteAPI::Camera.new
436
457
  # cam.change_function_to_shoot 'still'
458
+ #
437
459
  # # Start tracking focus from the center position
438
460
  # if cam.act_tracking_focus(50, 50)
439
461
  # th = cam.start_liveview_thread do |img, info|
@@ -489,7 +511,8 @@ module SonyCameraRemoteAPI
489
511
  # @example
490
512
  # # Initialize
491
513
  # cam = SonyCameraRemoteAPI::Camera.new
492
- # cam.change_function_to_shoot 'still', 'Single'
514
+ # cam.change_function_to_shoot 'still'
515
+ #
493
516
  # # Try to focus on upper-middle position.
494
517
  # if cam.act_tracking_focus(50, 10)
495
518
  # puts cam.focused?
@@ -1095,7 +1118,7 @@ module SonyCameraRemoteAPI
1095
1118
  # If error still continues, give it up and raise the error.
1096
1119
  def reconnect_and_retry(retrying: true, num: 1, hook: nil)
1097
1120
  yield
1098
- rescue HTTPClient::TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED => e
1121
+ rescue HTTPClient::BadResponseError, HTTPClient::TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED => e
1099
1122
  retry_count ||= 0
1100
1123
  raise e if @reconnect_by.nil? || retry_count >= num
1101
1124
  log.error "#{e.class}: #{e.message}"
@@ -1121,7 +1144,7 @@ module SonyCameraRemoteAPI
1121
1144
 
1122
1145
  def reconnect_and_retry_forever(&block)
1123
1146
  reconnect_and_retry &block
1124
- rescue HTTPClient::TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED => e
1147
+ rescue HTTPClient::BadResponseError, HTTPClient::TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED => e
1125
1148
  retry
1126
1149
  end
1127
1150
 
@@ -33,7 +33,7 @@ module SonyCameraRemoteAPI
33
33
 
34
34
 
35
35
  # getEvent API.
36
- # Long polling flag is set true as default.
36
+ # Long polling flag is set +true+ as default.
37
37
  # @param [Array,String] params
38
38
  # @return [Hash] Response of API
39
39
  def getEvent(params = [true], **opts)
@@ -64,12 +64,12 @@ module SonyCameraRemoteAPI
64
64
  # Wait until 'getEvent' result response meets the specified condition.
65
65
  # This method can be used to wait after calling APIs that change any camera parameters, such as 'setCameraFunction'.
66
66
  # @yield [Array<Hash>] The block that returns +true+ or +false+ based on the condition of the response of getEvent
67
- # @yieldparam [Array<Hash>] 'result' element in the response of getEvent
67
+ # @yieldparam [Array<Hash>] result the +result+ element in the response of +getEvent+
68
68
  # @param [Fixnum] timeout Timeout in seconds for changing parameter
69
- # @param [Boolean] polling This method has 3 patterns to handle long polling flag by 'polling' parameter.
69
+ # @param [Boolean] polling This method has 3 patterns to handle long polling flag by +polling+ argument.
70
70
  # * default : The first getEvent call doesn't use long polling, but then later always use long polling.
71
- # * polling = true : Always use long polling in getEvent call
72
- # * polling = false : Never use long polling in getEvent call
71
+ # * polling = +true+ : Always use long polling in getEvent call
72
+ # * polling = +false+ : Never use long polling in getEvent call
73
73
  # @raise EventTimeoutError
74
74
  # @todo add example
75
75
  def wait_event(timeout: DEFAULT_PARAM_CHANGE_TIMEOUT, polling: nil, &block)
@@ -98,14 +98,15 @@ module SonyCameraRemoteAPI
98
98
 
99
99
  # Ghost method, which handles almost API calls.
100
100
  # You can call an API as a method with the same name.
101
- # We don't have to specify service_type and version for almost APIs.
102
- # But some APIs have multiple service types and versions, so that we have to specify one service type or version.
103
- # When '!' is appended to the end of the method name, it does not raise Exception even if any error occurred.
101
+ # We don't have to specify service_type and version for almost APIs except some APIs
102
+ # having multiple service types and versions.
103
+ #
104
+ # When +!+ is appended to the end of the method name, it does not raise exception even if any error occurred.
104
105
  # @param [String] method
105
- # @param [Array,String] params
106
- # @param [String] service_type
107
- # @param [Fixnum] id
108
- # @param [String] version
106
+ # @param [Array,String] params 'params' element of the request
107
+ # @param [String] service_type Service type of the API
108
+ # @param [Fixnum] id ID for the request/response pair
109
+ # @param [String] version Version of the API
109
110
  # @param [Fixnum] timeout Timeout in seconds for waiting until the API is available
110
111
  # @example
111
112
  # # Initialize
@@ -120,7 +121,7 @@ module SonyCameraRemoteAPI
120
121
  # puts r
121
122
  # end
122
123
  #
123
- # # Call setCurrentTime API if supported.
124
+ # # Call setCurrentTime API if supported (does not raise exception if not supported)
124
125
  # cam.setCurrentTime! [{'dateTime' => Time.now.utc.iso8601,
125
126
  # 'timeZoneOffsetMinute' => 540,
126
127
  # 'dstOffsetMinute' => 0}]
@@ -137,10 +137,10 @@ module SonyCameraRemoteAPI
137
137
  # @example
138
138
  # # Initialize
139
139
  # cam = SonyCameraRemoteAPI::Camera.new
140
- # cam.change_function_to_shoot 'still', 'Single'
140
+ # cam.change_function_to_shoot 'still', 'Continuous'
141
141
  #
142
142
  # value = cam.get_current :ContShootingMode
143
- # puts value #=> 'Burst', 'MotionShot', Continuous' ...
143
+ # puts value #=> Continuous
144
144
  def get_current(group_name, **opts)
145
145
  get_parameter(group_name, available: false, supported: false, **opts)[:current]
146
146
  end
@@ -152,7 +152,7 @@ module SonyCameraRemoteAPI
152
152
  # @example
153
153
  # # Initialize
154
154
  # cam = SonyCameraRemoteAPI::Camera.new
155
- # cam.change_function_to_shoot 'still', 'Single'
155
+ # cam.change_function_to_shoot 'still', 'Continuous'
156
156
  #
157
157
  # value = cam.get_current! :ContShootingMode
158
158
  # if value
@@ -167,8 +167,8 @@ module SonyCameraRemoteAPI
167
167
 
168
168
  # Get supported/available/current value of the camera parameter.
169
169
  # @param [Symbol] group_name Parameter name
170
- # @param [Boolean] available Flag to get available values
171
- # @param [Boolean] supported Flag to get supported values
170
+ # @param [Boolean] available If +true+, available values are included to the returned hash.
171
+ # @param [Boolean] supported If +true+, supported values are returned to the returned hash.
172
172
  # @return [Hash] current/available/supported values
173
173
  # @raise APIForbidden, APINotSupported, APINotAvailable, IllegalArgument
174
174
  # @example
@@ -210,7 +210,7 @@ module SonyCameraRemoteAPI
210
210
  # @example
211
211
  # # Initialize
212
212
  # cam = SonyCameraRemoteAPI::Camera.new
213
- # cam.change_function_to_shoot 'still', 'Single'
213
+ # cam.change_function_to_shoot 'still'
214
214
  #
215
215
  # result = cam.get_parameter! :ExposureMode
216
216
  # if result[:current]
@@ -325,7 +325,7 @@ module SonyCameraRemoteAPI
325
325
 
326
326
 
327
327
  # Returns whether the parameter is supported or not.
328
- # @return [Boolean] +true+ if the parameter is supported, false otherwise.
328
+ # @return [Boolean] +true+ if the parameter is supported, +false+ otherwise.
329
329
  def support_group?(group_name)
330
330
  @api_groups.key? group_name
331
331
  end
@@ -15,7 +15,7 @@ module SonyCameraRemoteAPI
15
15
  module Client
16
16
 
17
17
  # Default config file saved in home directory.
18
- GLOBAL_CONFIG_FILE = File.expand_path('~/.sonycamconf')
18
+ GLOBAL_CONFIG_FILE = File.expand_path('~/.sonycam.shelf')
19
19
 
20
20
  # Main class of client
21
21
  class Main < Thor
@@ -37,43 +37,21 @@ module SonyCameraRemoteAPI
37
37
  options[:config] || GLOBAL_CONFIG_FILE
38
38
  end
39
39
 
40
- def load_camera_config
41
- # If SSID is specified, load the camera config.
42
- if options[:ssid]
43
- @shelf.get options[:ssid] || @shelf.get
44
- else
45
- @shelf.get
46
- end
47
- end
48
40
 
49
- # Load camera config and connect
50
- def load_and_connect
51
- config = load_camera_config
52
- unless config
53
- puts 'Failed to load camera config!'
41
+ # Initialize camera instance
42
+ def init_camera
43
+ @shelf = Shelf.new config_file
44
+ unless @shelf.select options[:ssid]
45
+ puts "No camera found having SSID #{options[:ssid]}"
54
46
  exit 1
55
47
  end
56
- unless Scripts.connect(config['interface'], config['ssid'], config['pass'])
48
+ unless @shelf.connect
57
49
  puts 'Failed to connect!'
58
50
  exit 1
59
51
  end
60
- config
61
- end
62
-
63
- # Initialize camera instance
64
- def init_camera
65
- @shelf = Shelf.new config_file
66
- config = load_and_connect
67
52
 
68
53
  puts 'Initializing camera...'
69
- if config['endpoints'].nil?
70
- @cam = SonyCameraRemoteAPI::Camera.new reconnect_by: method(:load_and_connect)
71
- @shelf.set_ep config['ssid'], @cam.endpoints
72
- puts 'SSDP configuration saved.'
73
- else
74
- @cam = SonyCameraRemoteAPI::Camera.new endpoints: config['endpoints'],
75
- reconnect_by: method(:load_and_connect)
76
- end
54
+ @cam = SonyCameraRemoteAPI::Camera.new @shelf
77
55
  puts 'Camera initialization finished.'
78
56
 
79
57
  # Change directory if --dir options specified
@@ -9,7 +9,7 @@ module SonyCameraRemoteAPI
9
9
  include Utils
10
10
 
11
11
  # Default config file saved in home directory.
12
- GLOBAL_CONFIG_FILE = File.expand_path('~/.sonycamconf')
12
+ GLOBAL_CONFIG_FILE = File.expand_path('~/.sonycam.shelf')
13
13
 
14
14
 
15
15
  # Create CameraShelf object.
@@ -1,4 +1,4 @@
1
1
  module SonyCameraRemoteAPI
2
2
  # Version
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.2.1'.freeze
4
4
  end
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
+ spec.required_ruby_version = ">= 2.0.0"
24
+
23
25
  spec.add_development_dependency "bundler", "~> 1.11"
24
26
  spec.add_development_dependency "rake", "~> 10.0"
25
27
  spec.add_development_dependency "rspec", "~> 3.5"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sony_camera_remote_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kota65535
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-25 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -216,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
216
216
  requirements:
217
217
  - - ">="
218
218
  - !ruby/object:Gem::Version
219
- version: '0'
219
+ version: 2.0.0
220
220
  required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  requirements:
222
222
  - - ">="