Class: RemoteDroid::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/remotedroid.rb

Instance Method Summary collapse

Constructor Details

#initialize(host = '127.0.0.1') ⇒ Client



847
848
849
# File 'lib/remotedroid.rb', line 847

def initialize(host='127.0.0.1')
  @drb = OneDrb::Client.new host: host, port: '5777'    
end

Instance Method Details

#batteryObject

– helpful methods —————–



882
883
884
# File 'lib/remotedroid.rb', line 882

def battery()
  query.battery
end

#cell_towerObject



886
887
888
# File 'lib/remotedroid.rb', line 886

def cell_tower()
  query.cell_tower
end

#controlObject



851
852
853
# File 'lib/remotedroid.rb', line 851

def control
  @drb.control
end

#export(s) ⇒ Object



855
856
857
# File 'lib/remotedroid.rb', line 855

def export(s)
  @drb.export(s)
end

#hotspot(state = nil) ⇒ Object



890
891
892
# File 'lib/remotedroid.rb', line 890

def hotspot(state=nil)      
  control.hotspot state
end

#invoke(s, *args) ⇒ Object



859
860
861
# File 'lib/remotedroid.rb', line 859

def invoke(s, *args)
  @drb.invoke(s, *args)
end

#locationObject



894
895
896
# File 'lib/remotedroid.rb', line 894

def location()
  query.location
end

#photoObject



898
899
900
# File 'lib/remotedroid.rb', line 898

def photo()
  take_picture
end

#query(id = nil) ⇒ Object



863
864
865
866
867
868
869
870
# File 'lib/remotedroid.rb', line 863

def query(id=nil)
  
  return @drb.query unless id
  t = Time.now
  h = @drb.query(id)
  h.merge({latency: (Time.now - t).round(3)})
  
end

#say(text) ⇒ Object



902
903
904
# File 'lib/remotedroid.rb', line 902

def say(text)
  control.speak_text text
end

#say_timeObject Also known as: saytime



906
907
908
# File 'lib/remotedroid.rb', line 906

def say_time()
  control.say_time
end

#screen(state = nil) ⇒ Object



912
913
914
# File 'lib/remotedroid.rb', line 912

def screen(state=nil)      
  control.screen state
end

#screen_offObject



920
921
922
# File 'lib/remotedroid.rb', line 920

def screen_off()
  screen :off
end

#screen_onObject



916
917
918
# File 'lib/remotedroid.rb', line 916

def screen_on()
  screen :on
end

#storeObject



876
877
878
# File 'lib/remotedroid.rb', line 876

def store()
  @drb.store
end

#take_photoObject



945
946
947
# File 'lib/remotedroid.rb', line 945

def take_photo()
  control.take_photo
end

#take_picture(ftp_src: nil, fileout: '.') ⇒ Object



924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
# File 'lib/remotedroid.rb', line 924

def take_picture(ftp_src: nil, fileout: '.')
  
  screen.on
  r = control.take_picture
        
  if ftp_src then
    
    # the sleep statement will be replaced in the near future, 
    # but it's fine to demonstrate it works
    sleep 8         
    
    credentials, dir = ftp_src.match(/(ftp:\/\/[^\/]+)\/([^$]+)/).captures
    ftp = MyMediaFTP.new(credentials)
    ftp.cd dir
    filename = ftp.ls.sort_by {|x| x[:ctime]}.last[:name]
    ftp.cp filename, fileout
    
  end
  
end

#torchObject



949
950
951
# File 'lib/remotedroid.rb', line 949

def torch()
  control.torch
end

#update(key, val) ⇒ Object



872
873
874
# File 'lib/remotedroid.rb', line 872

def update(key, val)
  @drb.update key.to_sym, val
end

#vibrateObject



953
954
955
# File 'lib/remotedroid.rb', line 953

def vibrate
  control.vibrate
end