Skip to content

Instantly share code, notes, and snippets.

@GOROman
Created January 25, 2015 07:04
Show Gist options
  • Save GOROman/65186bc1bbd7237113fb to your computer and use it in GitHub Desktop.
Save GOROman/65186bc1bbd7237113fb to your computer and use it in GitHub Desktop.
Wifi接続したGoProをRubyから制御するサンプル
#!ruby -Ku
# Wifi接続したGoProをRubyから制御するサンプル
# by GOROman
require 'net/http'
class GoProControl
def initialize( host )
@http = Net::HTTP.new( host )
@password = get_password()
end
def get_password
res = control( "bacpac", "sd" )
res.unpack("CCa*")[2]
end
def control( type, command, param = nil )
str = "/#{type}/#{command}"
str += "?t=#{@password}" if @password
str += "&p=%#{param}" if param
res = @http.get( str )
res.body
end
def shutter
control( "bacpac", "SH", "01" )
end
def mode( param )
control( "camera", "CM", param )
end
end
IP = "10.5.5.9"
camera = GoProControl.new( IP )
# 01:写真撮影モード
camera.mode( "01" )
# シャッターを切る
camera.shutter
@GOROman
Copy link
Author

GOROman commented Jan 25, 2015

制御コマンドについては

https://github.com/KonradIT/goprowifihack

を参考にしました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment