-
-
Save humboldt/559ff8fd1919a184e2d46202b15b1574 to your computer and use it in GitHub Desktop.
Revisions
-
GOROman created this gist
Jan 25, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ #!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