Class: RemoteDroid::Client
- Inherits:
-
Object
- Object
- RemoteDroid::Client
- Defined in:
- lib/remotedroid/client.rb
Instance Method Summary collapse
-
#ask_alexa ⇒ Object
– helpful methods —————–.
- #battery ⇒ Object
- #bluetooth ⇒ Object
- #cell_tower ⇒ Object
- #click(s) ⇒ Object
- #control ⇒ Object
- #control_media(option = 'Play/Pause') ⇒ Object
- #disable_airplane_mode ⇒ Object
- #disable_bluetooth ⇒ Object
- #disable_macro(macro) ⇒ Object
- #disable_wifi ⇒ Object
- #enable_airplane_mode ⇒ Object
- #enable_bluetooth ⇒ Object
- #enable_macro(macro) ⇒ Object
- #enable_wifi ⇒ Object
- #export(s) ⇒ Object
- #fill_clipboard(text) ⇒ Object (also: #copy)
- #hotspot(state = nil) ⇒ Object
-
#initialize(hostx = '127.0.0.1', host: hostx, port: '5777', sps_host: 'sps.home', sps_port: '59000') ⇒ Client
constructor
A new instance of Client.
- #invoke(s, *args) ⇒ Object
- #ip ⇒ Object
- #last_loc ⇒ Object
- #last_loc_link ⇒ Object
- #launch_activity(app) ⇒ Object (also: #launch)
- #launch_package(name) ⇒ Object
- #location ⇒ Object
- #location_watch(refresh: '1 minute', interval: refresh, duration: '30 minutes') ⇒ Object
- #macros ⇒ Object
- #next ⇒ Object
- #open_website(url) ⇒ Object (also: #goto, #visit)
- #pause ⇒ Object
- #photo ⇒ Object
- #play ⇒ Object
- #play_pause ⇒ Object
- #power_connected? ⇒ Boolean
- #previous ⇒ Object
- #query(id = nil) ⇒ Object
- #run_macro(name) ⇒ Object
- #say(text) ⇒ Object
- #say_time ⇒ Object (also: #saytime)
- #screen(state = nil) ⇒ Object
- #screen_off ⇒ Object
- #screen_on ⇒ Object
- #set_auto_rotate(state = nil) ⇒ Object
- #set_auto_rotate_off ⇒ Object
- #set_auto_rotate_on ⇒ Object
- #set_auto_rotate_toggle ⇒ Object
- #stay_awake ⇒ Object
- #stay_awake_off ⇒ Object (also: #awake_off)
- #stop ⇒ Object
- #store ⇒ Object
- #syslog ⇒ Object
- #take_picture(ftp_src: nil, fileout: '.') ⇒ Object (also: #take_photo)
- #take_screenshot(ftp_src: nil, fileout: '.') ⇒ Object
- #toggle_airplane_mode ⇒ Object
- #toggle_bluetooth ⇒ Object
- #toggle_wifi ⇒ Object
- #torch ⇒ Object
- #update(key, val) ⇒ Object
- #vibrate ⇒ Object
- #voice_search ⇒ Object
- #vol ⇒ Object
- #volume(context = nil) ⇒ Object
Constructor Details
#initialize(hostx = '127.0.0.1', host: hostx, port: '5777', sps_host: 'sps.home', sps_port: '59000') ⇒ Client
6 7 8 9 10 11 12 |
# File 'lib/remotedroid/client.rb', line 6 def initialize(hostx='127.0.0.1', host: hostx, port: '5777', sps_host: 'sps.home', sps_port: '59000') @drb = OneDrb::Client.new host: host, port: port @sps = SPSPub.new host: sps_host, port: sps_port end |
Instance Method Details
#ask_alexa ⇒ Object
– helpful methods —————–
58 59 60 |
# File 'lib/remotedroid/client.rb', line 58 def ask_alexa() control.ask_alexa end |
#battery ⇒ Object
62 63 64 |
# File 'lib/remotedroid/client.rb', line 62 def battery() query.battery end |
#bluetooth ⇒ Object
66 67 68 |
# File 'lib/remotedroid/client.rb', line 66 def bluetooth() control.bluetooth end |
#cell_tower ⇒ Object
70 71 72 |
# File 'lib/remotedroid/client.rb', line 70 def cell_tower() query.cell_tower end |
#click(s) ⇒ Object
74 75 76 |
# File 'lib/remotedroid/client.rb', line 74 def click(s) control.click content: s end |
#control ⇒ Object
14 15 16 |
# File 'lib/remotedroid/client.rb', line 14 def control @drb.control end |
#control_media(option = 'Play/Pause') ⇒ Object
78 79 80 |
# File 'lib/remotedroid/client.rb', line 78 def control_media(option='Play/Pause') control.control_media({option: option}) end |
#disable_airplane_mode ⇒ Object
82 83 84 |
# File 'lib/remotedroid/client.rb', line 82 def disable_airplane_mode() control.disable_airplane_mode end |
#disable_bluetooth ⇒ Object
86 87 88 |
# File 'lib/remotedroid/client.rb', line 86 def disable_bluetooth() control.disable_bluetooth end |
#disable_macro(macro) ⇒ Object
90 91 92 |
# File 'lib/remotedroid/client.rb', line 90 def disable_macro(macro) control.disable_macro macro end |
#disable_wifi ⇒ Object
94 95 96 |
# File 'lib/remotedroid/client.rb', line 94 def disable_wifi() control.disable_wifi end |
#enable_airplane_mode ⇒ Object
98 99 100 |
# File 'lib/remotedroid/client.rb', line 98 def enable_airplane_mode() control.enable_airplane_mode end |
#enable_bluetooth ⇒ Object
102 103 104 |
# File 'lib/remotedroid/client.rb', line 102 def enable_bluetooth() control.enable_bluetooth end |
#enable_macro(macro) ⇒ Object
106 107 108 |
# File 'lib/remotedroid/client.rb', line 106 def enable_macro(macro) control.enable_macro macro end |
#enable_wifi ⇒ Object
110 111 112 |
# File 'lib/remotedroid/client.rb', line 110 def enable_wifi() control.enable_wifi end |
#export(s) ⇒ Object
18 19 20 |
# File 'lib/remotedroid/client.rb', line 18 def export(s) @drb.export(s) end |
#fill_clipboard(text) ⇒ Object Also known as: copy
114 115 116 |
# File 'lib/remotedroid/client.rb', line 114 def fill_clipboard(text) control.fill_clipboard clipboard: text end |
#hotspot(state = nil) ⇒ Object
120 121 122 |
# File 'lib/remotedroid/client.rb', line 120 def hotspot(state=nil) control.hotspot state end |
#invoke(s, *args) ⇒ Object
22 23 24 |
# File 'lib/remotedroid/client.rb', line 22 def invoke(s, *args) @drb.invoke(s, *args) end |
#ip ⇒ Object
186 187 188 |
# File 'lib/remotedroid/client.rb', line 186 def ip() query.ip end |
#last_loc ⇒ Object
124 125 126 |
# File 'lib/remotedroid/client.rb', line 124 def last_loc() query.last_loc end |
#last_loc_link ⇒ Object
128 129 130 |
# File 'lib/remotedroid/client.rb', line 128 def last_loc_link() "<a href='%s' target='_blank'>map link</a>" % last_loc.link end |
#launch_activity(app) ⇒ Object Also known as: launch
132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/remotedroid/client.rb', line 132 def launch_activity(app) package = APPS[app] if package then control.launch_package package: package else r = APPS.find {|k,v| k =~ /#{app}/i} control.launch_package(package: r[1]) if r end end |
#launch_package(name) ⇒ Object
145 146 147 148 149 |
# File 'lib/remotedroid/client.rb', line 145 def launch_package(name) control.launch_package(package: name) end |
#location ⇒ Object
153 154 155 |
# File 'lib/remotedroid/client.rb', line 153 def location() query.location end |
#location_watch(refresh: '1 minute', interval: refresh, duration: '30 minutes') ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/remotedroid/client.rb', line 157 def location_watch(refresh: '1 minute', interval: refresh, duration: '30 minutes') d = ChronicDuration.parse(duration) seconds = ChronicDuration.parse(interval) puts ("monitoring location every %s for %s" % [interval, duration]).info Thread.new do t = Time.now + d begin query.location sleep seconds end until Time.now >= t end end |
#macros ⇒ Object
26 27 28 |
# File 'lib/remotedroid/client.rb', line 26 def macros() @drb.macros end |
#next ⇒ Object
190 191 192 |
# File 'lib/remotedroid/client.rb', line 190 def next() control_media('Next') end |
#open_website(url) ⇒ Object Also known as: goto, visit
179 180 181 |
# File 'lib/remotedroid/client.rb', line 179 def open_website(url) control.open_website url: url end |
#pause ⇒ Object
194 195 196 |
# File 'lib/remotedroid/client.rb', line 194 def pause() control_media('Pause') end |
#photo ⇒ Object
206 207 208 |
# File 'lib/remotedroid/client.rb', line 206 def photo() take_picture end |
#play ⇒ Object
198 199 200 |
# File 'lib/remotedroid/client.rb', line 198 def play() control_media('Play') end |
#play_pause ⇒ Object
202 203 204 |
# File 'lib/remotedroid/client.rb', line 202 def play_pause() control_media('Play/Pause') end |
#power_connected? ⇒ Boolean
210 211 212 |
# File 'lib/remotedroid/client.rb', line 210 def power_connected?() query.power_connected? end |
#previous ⇒ Object
214 215 216 |
# File 'lib/remotedroid/client.rb', line 214 def previous() control.control_media(option: 'Previous') end |
#query(id = nil) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/remotedroid/client.rb', line 30 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 |
#run_macro(name) ⇒ Object
39 40 41 42 |
# File 'lib/remotedroid/client.rb', line 39 def run_macro(name) a = @drb.run_macro name a.each {|msg| @sps.notice 'macrodroid/action: ' + msg } end |
#say(text) ⇒ Object
218 219 220 |
# File 'lib/remotedroid/client.rb', line 218 def say(text) control.speak_text text end |
#say_time ⇒ Object Also known as: saytime
222 223 224 |
# File 'lib/remotedroid/client.rb', line 222 def say_time() control.say_time end |
#screen(state = nil) ⇒ Object
228 229 230 |
# File 'lib/remotedroid/client.rb', line 228 def screen(state=nil) control.screen state end |
#screen_off ⇒ Object
236 237 238 |
# File 'lib/remotedroid/client.rb', line 236 def screen_off() screen :off end |
#screen_on ⇒ Object
232 233 234 |
# File 'lib/remotedroid/client.rb', line 232 def screen_on() screen :on end |
#set_auto_rotate(state = nil) ⇒ Object
240 241 242 |
# File 'lib/remotedroid/client.rb', line 240 def set_auto_rotate(state=nil) control.set_auto_rotate state end |
#set_auto_rotate_off ⇒ Object
248 249 250 |
# File 'lib/remotedroid/client.rb', line 248 def set_auto_rotate_off() control.set_auto_rotate 1 end |
#set_auto_rotate_on ⇒ Object
244 245 246 |
# File 'lib/remotedroid/client.rb', line 244 def set_auto_rotate_on() control.set_auto_rotate 0 end |
#set_auto_rotate_toggle ⇒ Object
252 253 254 |
# File 'lib/remotedroid/client.rb', line 252 def set_auto_rotate_toggle() control.set_auto_rotate 2 end |
#stay_awake ⇒ Object
256 257 258 |
# File 'lib/remotedroid/client.rb', line 256 def stay_awake() control.stay_awake end |
#stay_awake_off ⇒ Object Also known as: awake_off
260 261 262 |
# File 'lib/remotedroid/client.rb', line 260 def stay_awake_off() control.stay_awake_off end |
#stop ⇒ Object
266 267 268 |
# File 'lib/remotedroid/client.rb', line 266 def stop() control_media(option: 'Stop') end |
#store ⇒ Object
48 49 50 |
# File 'lib/remotedroid/client.rb', line 48 def store() @drb.store end |
#syslog ⇒ Object
52 53 54 |
# File 'lib/remotedroid/client.rb', line 52 def syslog() @drb.syslog end |
#take_picture(ftp_src: nil, fileout: '.') ⇒ Object Also known as: take_photo
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/remotedroid/client.rb', line 270 def take_picture(ftp_src: nil, fileout: '.') #screen.on #launch 'camera' if ftp_src then r = query.take_picture # give the device a second to write the image to file sleep 1 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 else contro.take_picture end end |
#take_screenshot(ftp_src: nil, fileout: '.') ⇒ Object
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/remotedroid/client.rb', line 297 def take_screenshot(ftp_src: nil, fileout: '.') #screen.on if ftp_src then r = query.take_screenshot # give the device a second to write the image to file sleep 1 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 |
#toggle_airplane_mode ⇒ Object
318 319 320 |
# File 'lib/remotedroid/client.rb', line 318 def toggle_airplane_mode() control.toggle_airplane_mode end |
#toggle_bluetooth ⇒ Object
322 323 324 |
# File 'lib/remotedroid/client.rb', line 322 def toggle_bluetooth() control.toggle_bluetooth end |
#toggle_wifi ⇒ Object
326 327 328 |
# File 'lib/remotedroid/client.rb', line 326 def toggle_wifi() control.toggle_wifi end |
#torch ⇒ Object
330 331 332 |
# File 'lib/remotedroid/client.rb', line 330 def torch() control.torch end |
#update(key, val) ⇒ Object
44 45 46 |
# File 'lib/remotedroid/client.rb', line 44 def update(key, val) @drb.update key.to_sym, val end |
#vibrate ⇒ Object
334 335 336 |
# File 'lib/remotedroid/client.rb', line 334 def vibrate control.vibrate end |
#voice_search ⇒ Object
338 339 340 |
# File 'lib/remotedroid/client.rb', line 338 def voice_search control.voice_search end |
#vol ⇒ Object
346 347 348 |
# File 'lib/remotedroid/client.rb', line 346 def vol() volume.music end |
#volume(context = nil) ⇒ Object
342 343 344 |
# File 'lib/remotedroid/client.rb', line 342 def volume(context=nil) query.volume context end |