Skip to content

Connect your PC to the camera

Tomohiko Ozawa edited this page Oct 4, 2016 · 1 revision

The first step to utilize Sony Camera Remote API is connecting your camera to the PC (or device) with Direct Wi-Fi. Maybe you want to do it programmatically like Android or iOS rather than clicking buttons, don't you? If you are using Linux or MacOS machine, you can use SonyCameraRemoteAPI::Shelf class the enables you to manage Wi-Fi connectivity for multiple cameras.

To initialize Shelf class, you have to specify the configuration file path where Wi-Fi configurations are saved. If not specified, the default path ~/sonycam.shelf is used. Then, add your camera's Wi-Fi configuration by shelf#add. It consists of 3 elements: SSID, password and interface by which you connect. Once cameras are added, they are saved immediately to the configuration file. So you don't have to add cameras each time.

require 'sony_camera_remote_api'

shelf = SonyCameraRemoteAPI::Shelf.new
shelf.add 'DIRECT-xxxx:HDR-AZ1', 'passwd00', 'wlan0'
shelf.add 'DIRECT-xxxx:ILCE-QX1', 'passwd01', 'wlan0'

To select the camera you want to use from the above, call shelf#select with its SSID. Given SSID can be its partial string as long as it is unique among all cameras. You can connect to the selected camera by calling shelf#connect. It returns true if succeeded, otherwise false.

shelf.select 'AZ1'
unless shelf.connect
  puts 'Failed to connect!'
  exit 1
end

After connection is succeeded, all you have to do is creating a SonyRemoteCameraAPI::Camera class instance, which is the entry-point of all APIs and wrapper methods. It can be initialized by giving Shelf instance.

cam = SonyCameraRemoteAPI::Camera.new shelf

Excellent! Let's move on the other tutorials of the various useful shooting functions.