- 
      
 - 
        
Save humboldt/559ff8fd1919a184e2d46202b15b1574 to your computer and use it in GitHub Desktop.  
    Wifi接続したGoProをRubyから制御するサンプル
  
        
  
    
      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 characters
    
  
  
    
  | #!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 | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment