remotedroid 0.2.0 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/remotedroid.rb +448 -18
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 93065c866dfef9501613644d3f1ec4f18fd7ba5459c62645eb97bbdfb6069b89
|
|
4
|
+
data.tar.gz: 8ae132d997c1c7072383eb6878e757bbcc7deeb1241d783d261a2d4885bd0c42
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 548cc195f2f8525be869c8429dbb1ede8c9da42ba3ff489b347b204f2bdcb630e09b5d012b4c496ff49bcd2ec6d94bccfc968ff9d4cfbe4d057186bc6209d991
|
|
7
|
+
data.tar.gz: 5b5eff2de32dfe89a2110558bce22e1a11ddf4cc6ed9d69e903b6c087575e5a9e48e20fbea39a95eade2d69e67b6d49db7ae68874e947aa93ae4a8896852cbf6
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/lib/remotedroid.rb
CHANGED
|
@@ -13,6 +13,10 @@ require 'ruby-macrodroid'
|
|
|
13
13
|
#
|
|
14
14
|
# # Triggers
|
|
15
15
|
#
|
|
16
|
+
# ## Device Events
|
|
17
|
+
#
|
|
18
|
+
# * screen on
|
|
19
|
+
#
|
|
16
20
|
# ## Sensors
|
|
17
21
|
#
|
|
18
22
|
# * proximity (near)
|
|
@@ -22,6 +26,14 @@ require 'ruby-macrodroid'
|
|
|
22
26
|
#
|
|
23
27
|
# # Actions
|
|
24
28
|
#
|
|
29
|
+
# ## Camera/Photo
|
|
30
|
+
#
|
|
31
|
+
# * Take Picture
|
|
32
|
+
#
|
|
33
|
+
# ## Connectivity
|
|
34
|
+
#
|
|
35
|
+
# * Enable HotSpot
|
|
36
|
+
#
|
|
25
37
|
# ## Date/Time
|
|
26
38
|
#
|
|
27
39
|
# * Say Current Time
|
|
@@ -30,16 +42,70 @@ require 'ruby-macrodroid'
|
|
|
30
42
|
#
|
|
31
43
|
# * Speak text
|
|
32
44
|
# * Torch toggle
|
|
45
|
+
# * vibrate
|
|
33
46
|
#
|
|
34
47
|
# ## Location
|
|
35
48
|
#
|
|
36
49
|
# * Share Location
|
|
37
50
|
#
|
|
51
|
+
# ## Media
|
|
52
|
+
#
|
|
53
|
+
# * Play sound (Doda)
|
|
54
|
+
#
|
|
38
55
|
# ## Notification
|
|
39
56
|
#
|
|
40
57
|
# * Popup Message
|
|
41
58
|
#
|
|
59
|
+
# ## Screen
|
|
60
|
+
#
|
|
61
|
+
# * Screen On
|
|
62
|
+
#
|
|
42
63
|
|
|
64
|
+
# Variables which can be queried
|
|
65
|
+
#
|
|
66
|
+
# Description Variable
|
|
67
|
+
# ------------------- ----------------
|
|
68
|
+
# Foreground app name :fg_app_name
|
|
69
|
+
# Foreground app package :fg_app_package
|
|
70
|
+
# Current Brightness :current_brightness
|
|
71
|
+
# Screen timeout (seconds) :screen_timeout
|
|
72
|
+
# Current battery % :battery
|
|
73
|
+
# Battery temp °C :battery_temp
|
|
74
|
+
# Power (On/Off) :power
|
|
75
|
+
# Clipboard text :clipboard
|
|
76
|
+
# Current IP address :ip
|
|
77
|
+
# Wifi SSID :ssid
|
|
78
|
+
# Wifi signal strength :wifi_strength
|
|
79
|
+
# System time :system_time
|
|
80
|
+
# IMEI :imei
|
|
81
|
+
# Cell Id :cell_id
|
|
82
|
+
# Last known location (lat,lon) :last_loc_latlong
|
|
83
|
+
# Last known location (altitude) :last_loc_alt
|
|
84
|
+
# Last known location (link) :last_loc_link
|
|
85
|
+
# Last known location (time) :last_loc_age_timestamp
|
|
86
|
+
# Last known location (kmh) :last_loc_speed_kmh
|
|
87
|
+
# Last known location (mph) :last_loc_speed_mph
|
|
88
|
+
# Current Volume (Alarm) :vol_alarm
|
|
89
|
+
# Current Volume (Media / Music) :vol_music
|
|
90
|
+
# Current Volume (Ringer) :vol_ring
|
|
91
|
+
# Current Volume (Notification) :vol_notif
|
|
92
|
+
# Current Volume (System Sounds) :vol_system
|
|
93
|
+
# Current Volume (Voice Call) :vol_call
|
|
94
|
+
# Current Volume (Bluetooth Voice) :vol_bt_voice
|
|
95
|
+
# Device name :device_name
|
|
96
|
+
# Device uptime :uptime_secs
|
|
97
|
+
# Device manufacturer :device_manufacturer
|
|
98
|
+
# Device model :device_model
|
|
99
|
+
# Android version :android_version
|
|
100
|
+
# Android version (SDK Level) :android_version_sdk
|
|
101
|
+
# Storage total (external) :storage_external_total
|
|
102
|
+
# Storage free (external) :storage_external_free
|
|
103
|
+
# Storage total (internal) :storage_internal_total
|
|
104
|
+
# Storage free (internal) :storage_internal_free
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# The macros below are exported to JSON format as a file which is imported into
|
|
108
|
+
# the Android device running MacroDroid.
|
|
43
109
|
|
|
44
110
|
RD_MACROS =<<EOF
|
|
45
111
|
m: Camera flash light
|
|
@@ -66,6 +132,40 @@ v: text
|
|
|
66
132
|
t: webhook
|
|
67
133
|
a: speak text ([lv=text])
|
|
68
134
|
|
|
135
|
+
m: vibrate
|
|
136
|
+
t: webhook
|
|
137
|
+
a: vibrate
|
|
138
|
+
|
|
139
|
+
m: play doda
|
|
140
|
+
t: webhook
|
|
141
|
+
a: play: Doda
|
|
142
|
+
|
|
143
|
+
m: Screen
|
|
144
|
+
v: on: false
|
|
145
|
+
t: WebHook
|
|
146
|
+
a:
|
|
147
|
+
If on = True
|
|
148
|
+
Screen On
|
|
149
|
+
Else
|
|
150
|
+
Screen Off
|
|
151
|
+
End If
|
|
152
|
+
|
|
153
|
+
m: Hotspot
|
|
154
|
+
v: enable: false
|
|
155
|
+
t: WebHook
|
|
156
|
+
a:
|
|
157
|
+
If enable = True
|
|
158
|
+
Enable Hotspot
|
|
159
|
+
Else
|
|
160
|
+
Disable Hotspot
|
|
161
|
+
End If
|
|
162
|
+
|
|
163
|
+
m: Take Picture
|
|
164
|
+
t: webhook
|
|
165
|
+
a:
|
|
166
|
+
Take Picture
|
|
167
|
+
Rear Facing
|
|
168
|
+
|
|
69
169
|
m: Share location
|
|
70
170
|
t:
|
|
71
171
|
WebHook
|
|
@@ -78,7 +178,49 @@ a:
|
|
|
78
178
|
HTTP GET
|
|
79
179
|
identifier: location
|
|
80
180
|
coords: [lv=coords]
|
|
181
|
+
type: query
|
|
81
182
|
|
|
183
|
+
m: query
|
|
184
|
+
t: WebHook
|
|
185
|
+
v: qvar
|
|
186
|
+
a:
|
|
187
|
+
Set Variable
|
|
188
|
+
var: [[lv=qvar]]
|
|
189
|
+
a:
|
|
190
|
+
HTTP GET
|
|
191
|
+
[lv=qvar]: [lv=var]
|
|
192
|
+
|
|
193
|
+
m: query setting system
|
|
194
|
+
t: WebHook
|
|
195
|
+
v: qvar
|
|
196
|
+
a:
|
|
197
|
+
Set Variable
|
|
198
|
+
var: [setting_system=[lv=qvar]]
|
|
199
|
+
a:
|
|
200
|
+
HTTP GET
|
|
201
|
+
[lv=qvar]: [lv=var]
|
|
202
|
+
|
|
203
|
+
m: query setting global
|
|
204
|
+
t: WebHook
|
|
205
|
+
v: qvar
|
|
206
|
+
a:
|
|
207
|
+
Set Variable
|
|
208
|
+
var: [setting_global=[lv=qvar]]
|
|
209
|
+
a:
|
|
210
|
+
HTTP GET
|
|
211
|
+
[lv=qvar]: [lv=var]
|
|
212
|
+
|
|
213
|
+
m: query setting secure
|
|
214
|
+
t: WebHook
|
|
215
|
+
v: qvar
|
|
216
|
+
a:
|
|
217
|
+
Set Variable
|
|
218
|
+
var: [setting_secure=[lv=qvar]]
|
|
219
|
+
a:
|
|
220
|
+
HTTP GET
|
|
221
|
+
[lv=qvar]: [lv=var]
|
|
222
|
+
|
|
223
|
+
|
|
82
224
|
m: shake device
|
|
83
225
|
t: shake device
|
|
84
226
|
a: webhook
|
|
@@ -89,9 +231,30 @@ a:
|
|
|
89
231
|
webhook
|
|
90
232
|
identifier: proximity
|
|
91
233
|
option: 0
|
|
234
|
+
|
|
235
|
+
m: Power connected
|
|
236
|
+
t: Power Connected: Any
|
|
237
|
+
a: webhook
|
|
238
|
+
|
|
239
|
+
m: screen on off
|
|
240
|
+
t: screen on
|
|
241
|
+
a: webhook
|
|
92
242
|
|
|
93
243
|
EOF
|
|
94
244
|
|
|
245
|
+
=begin
|
|
246
|
+
m: Screen
|
|
247
|
+
v: on: true
|
|
248
|
+
t: WebHook
|
|
249
|
+
a:
|
|
250
|
+
If on = true
|
|
251
|
+
Screen On
|
|
252
|
+
Else
|
|
253
|
+
Screen Off
|
|
254
|
+
End If
|
|
255
|
+
|
|
256
|
+
=end
|
|
257
|
+
|
|
95
258
|
module RemoteDroid
|
|
96
259
|
|
|
97
260
|
class Model
|
|
@@ -322,7 +485,7 @@ module RemoteDroid
|
|
|
322
485
|
class Controller
|
|
323
486
|
|
|
324
487
|
attr_reader :model, :control
|
|
325
|
-
attr_accessor :title, :macros
|
|
488
|
+
attr_accessor :title, :macros, :store
|
|
326
489
|
|
|
327
490
|
def initialize(mcs, model=MODEL, deviceid: nil, debug: false)
|
|
328
491
|
|
|
@@ -335,6 +498,9 @@ module RemoteDroid
|
|
|
335
498
|
if model then
|
|
336
499
|
@model = Model.new(model)
|
|
337
500
|
end
|
|
501
|
+
|
|
502
|
+
@store = {}
|
|
503
|
+
@query = Query.new(self)
|
|
338
504
|
|
|
339
505
|
end
|
|
340
506
|
|
|
@@ -343,7 +509,12 @@ module RemoteDroid
|
|
|
343
509
|
end
|
|
344
510
|
|
|
345
511
|
def invoke(name, options={})
|
|
346
|
-
|
|
512
|
+
|
|
513
|
+
if @control.respond_to? name.to_sym then
|
|
514
|
+
@control.method(name.to_sym).call(options)
|
|
515
|
+
else
|
|
516
|
+
@control.http_exec name.to_sym, options
|
|
517
|
+
end
|
|
347
518
|
end
|
|
348
519
|
|
|
349
520
|
# Object Property (op)
|
|
@@ -354,12 +525,33 @@ module RemoteDroid
|
|
|
354
525
|
@model.op
|
|
355
526
|
end
|
|
356
527
|
|
|
357
|
-
def query(
|
|
528
|
+
def query(id=nil)
|
|
529
|
+
|
|
530
|
+
return @query unless id
|
|
531
|
+
|
|
532
|
+
@store[id] = nil
|
|
533
|
+
|
|
534
|
+
sys = %i(accelerometer_rotation)
|
|
358
535
|
|
|
359
|
-
|
|
536
|
+
global = [:airplane_mode_on, :bluetooth_on, :cell_on, :device_name, \
|
|
537
|
+
:usb_mass_storage_enabled, :wifi_on]
|
|
538
|
+
|
|
539
|
+
secure = %i(bluetooth_name flashlight_enabled)
|
|
540
|
+
|
|
360
541
|
|
|
361
542
|
# send http request via macrodroid.com API
|
|
362
|
-
|
|
543
|
+
|
|
544
|
+
if id.downcase.to_sym == :location then
|
|
545
|
+
@control.http_exec id
|
|
546
|
+
elsif sys.include? id
|
|
547
|
+
@control.http_exec :'query-setting-system', {qvar: id}
|
|
548
|
+
elsif global.include? id
|
|
549
|
+
@control.http_exec :'query-setting-global', {qvar: id}
|
|
550
|
+
elsif secure.include? id
|
|
551
|
+
@control.http_exec :'query-setting-secure', {qvar: id}
|
|
552
|
+
else
|
|
553
|
+
@control.http_exec :query, {qvar: id}
|
|
554
|
+
end
|
|
363
555
|
|
|
364
556
|
# wait for the local variable to be updated
|
|
365
557
|
# timeout after 5 seoncds
|
|
@@ -367,11 +559,12 @@ module RemoteDroid
|
|
|
367
559
|
|
|
368
560
|
begin
|
|
369
561
|
sleep 1
|
|
370
|
-
end until @
|
|
562
|
+
end until @store[id] or Time.now > t + 5
|
|
371
563
|
|
|
372
|
-
if
|
|
373
|
-
|
|
374
|
-
|
|
564
|
+
return {warning: 'HTTP response timeout'} if Time.now > t+5
|
|
565
|
+
|
|
566
|
+
return @store[id]
|
|
567
|
+
|
|
375
568
|
|
|
376
569
|
end
|
|
377
570
|
|
|
@@ -408,10 +601,12 @@ module RemoteDroid
|
|
|
408
601
|
end
|
|
409
602
|
|
|
410
603
|
alias trigger_fired trigger
|
|
604
|
+
|
|
605
|
+
def update(id, val)
|
|
606
|
+
key = id == :location ? id : val.keys.first.to_sym
|
|
607
|
+
@store[key] = val
|
|
608
|
+
end
|
|
411
609
|
|
|
412
|
-
def store()
|
|
413
|
-
@h
|
|
414
|
-
end
|
|
415
610
|
|
|
416
611
|
end
|
|
417
612
|
|
|
@@ -441,6 +636,13 @@ module RemoteDroid
|
|
|
441
636
|
end
|
|
442
637
|
|
|
443
638
|
end
|
|
639
|
+
|
|
640
|
+
class ControlHelper
|
|
641
|
+
|
|
642
|
+
def initialize(callback)
|
|
643
|
+
@callback
|
|
644
|
+
end
|
|
645
|
+
end
|
|
444
646
|
|
|
445
647
|
class Control
|
|
446
648
|
|
|
@@ -448,7 +650,7 @@ module RemoteDroid
|
|
|
448
650
|
|
|
449
651
|
@deviceid, @remote_url, @debug = deviceid, remote_url, debug
|
|
450
652
|
@torch = Torch.new(self)
|
|
451
|
-
end
|
|
653
|
+
end
|
|
452
654
|
|
|
453
655
|
def bluetooth()
|
|
454
656
|
@bluetooth
|
|
@@ -457,6 +659,33 @@ module RemoteDroid
|
|
|
457
659
|
def camera_flash_light(options={})
|
|
458
660
|
http_exec 'camera-flash-light', options
|
|
459
661
|
end
|
|
662
|
+
|
|
663
|
+
def hotspot(state=nil)
|
|
664
|
+
|
|
665
|
+
if state then
|
|
666
|
+
http_exec 'hotspot', {enable: state == :enable}
|
|
667
|
+
else
|
|
668
|
+
|
|
669
|
+
def self.enable()
|
|
670
|
+
http_exec 'hotspot', {enable: true}
|
|
671
|
+
end
|
|
672
|
+
|
|
673
|
+
def self.on()
|
|
674
|
+
self.enable
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
def self.disable()
|
|
678
|
+
http_exec 'hotspot', {enable: false}
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
def self.off()
|
|
682
|
+
self.disable
|
|
683
|
+
end
|
|
684
|
+
|
|
685
|
+
self
|
|
686
|
+
|
|
687
|
+
end
|
|
688
|
+
end
|
|
460
689
|
|
|
461
690
|
def http_exec(command, options={})
|
|
462
691
|
|
|
@@ -482,14 +711,50 @@ module RemoteDroid
|
|
|
482
711
|
|
|
483
712
|
alias say_time say_current_time
|
|
484
713
|
|
|
714
|
+
def screen(state=nil)
|
|
715
|
+
|
|
716
|
+
if state then
|
|
717
|
+
http_exec 'screen', {on: state == :on}
|
|
718
|
+
else
|
|
719
|
+
|
|
720
|
+
def self.on()
|
|
721
|
+
http_exec 'screen', {on: true}
|
|
722
|
+
end
|
|
723
|
+
|
|
724
|
+
def self.off()
|
|
725
|
+
http_exec 'screen', {on: false}
|
|
726
|
+
end
|
|
727
|
+
|
|
728
|
+
self
|
|
729
|
+
|
|
730
|
+
end
|
|
731
|
+
end
|
|
732
|
+
|
|
485
733
|
def share_location(options={})
|
|
486
734
|
http_exec 'share-location'
|
|
487
735
|
end
|
|
488
736
|
|
|
489
|
-
def speak_text(
|
|
737
|
+
def speak_text(obj)
|
|
738
|
+
|
|
739
|
+
options = case obj
|
|
740
|
+
when String
|
|
741
|
+
{text: obj}
|
|
742
|
+
when Hash
|
|
743
|
+
obj
|
|
744
|
+
end
|
|
745
|
+
|
|
490
746
|
http_exec 'speak-text', options
|
|
491
747
|
end
|
|
492
748
|
|
|
749
|
+
alias say speak_text
|
|
750
|
+
|
|
751
|
+
def take_picture(options={})
|
|
752
|
+
http_exec :'take-picture', options
|
|
753
|
+
end
|
|
754
|
+
|
|
755
|
+
alias take_photo take_picture
|
|
756
|
+
|
|
757
|
+
|
|
493
758
|
def toast(options={})
|
|
494
759
|
http_exec :toast, options
|
|
495
760
|
end
|
|
@@ -497,6 +762,10 @@ module RemoteDroid
|
|
|
497
762
|
def torch(options={})
|
|
498
763
|
http_exec :torch
|
|
499
764
|
end
|
|
765
|
+
|
|
766
|
+
def vibrate(options={})
|
|
767
|
+
http_exec :vibrate
|
|
768
|
+
end
|
|
500
769
|
|
|
501
770
|
|
|
502
771
|
def write(s)
|
|
@@ -508,12 +777,55 @@ module RemoteDroid
|
|
|
508
777
|
|
|
509
778
|
alias export write
|
|
510
779
|
|
|
511
|
-
def
|
|
780
|
+
def method_missing2(method_name, *args)
|
|
512
781
|
http_exec(method_name, args.first)
|
|
513
782
|
end
|
|
514
783
|
|
|
515
784
|
end
|
|
516
785
|
|
|
786
|
+
class Query
|
|
787
|
+
|
|
788
|
+
def initialize(callback)
|
|
789
|
+
@callback = callback
|
|
790
|
+
end
|
|
791
|
+
|
|
792
|
+
def airplane_mode_enabled?()
|
|
793
|
+
q(:airplane_mode_on).to_i > 0
|
|
794
|
+
end
|
|
795
|
+
|
|
796
|
+
def battery()
|
|
797
|
+
q(:battery).to_i
|
|
798
|
+
end
|
|
799
|
+
|
|
800
|
+
def current_brightness()
|
|
801
|
+
q(:current_brightness).to_i
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
alias brightness current_brightness
|
|
805
|
+
|
|
806
|
+
def cell_id()
|
|
807
|
+
q(:cell_id)
|
|
808
|
+
end
|
|
809
|
+
|
|
810
|
+
alias cell_tower cell_id
|
|
811
|
+
|
|
812
|
+
def ip()
|
|
813
|
+
q(:ip)
|
|
814
|
+
end
|
|
815
|
+
|
|
816
|
+
def location()
|
|
817
|
+
@callback.query(:location)[:coords]
|
|
818
|
+
end
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
private
|
|
822
|
+
|
|
823
|
+
def q(id)
|
|
824
|
+
@callback.query(id)[id]
|
|
825
|
+
end
|
|
826
|
+
|
|
827
|
+
end
|
|
828
|
+
|
|
517
829
|
class Server
|
|
518
830
|
|
|
519
831
|
def initialize(s, drb_host: '127.0.0.1', deviceid: nil)
|
|
@@ -536,6 +848,10 @@ module RemoteDroid
|
|
|
536
848
|
@drb = OneDrb::Client.new host: host, port: '5777'
|
|
537
849
|
end
|
|
538
850
|
|
|
851
|
+
def control
|
|
852
|
+
@drb.control
|
|
853
|
+
end
|
|
854
|
+
|
|
539
855
|
def export(s)
|
|
540
856
|
@drb.export(s)
|
|
541
857
|
end
|
|
@@ -543,13 +859,107 @@ module RemoteDroid
|
|
|
543
859
|
def invoke(s, *args)
|
|
544
860
|
@drb.invoke(s, *args)
|
|
545
861
|
end
|
|
862
|
+
|
|
863
|
+
def query(id=nil)
|
|
864
|
+
|
|
865
|
+
return @drb.query unless id
|
|
866
|
+
t = Time.now
|
|
867
|
+
h = @drb.query(id)
|
|
868
|
+
h.merge({latency: (Time.now - t).round(3)})
|
|
869
|
+
|
|
870
|
+
end
|
|
871
|
+
|
|
872
|
+
def update(key, val)
|
|
873
|
+
@drb.update key.to_sym, val
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
def store()
|
|
877
|
+
@drb.store
|
|
878
|
+
end
|
|
879
|
+
|
|
880
|
+
# -- helpful methods -----------------
|
|
881
|
+
|
|
882
|
+
def battery()
|
|
883
|
+
query.battery
|
|
884
|
+
end
|
|
885
|
+
|
|
886
|
+
def cell_tower()
|
|
887
|
+
query.cell_tower
|
|
888
|
+
end
|
|
889
|
+
|
|
890
|
+
def hotspot(state=nil)
|
|
891
|
+
control.hotspot state
|
|
892
|
+
end
|
|
893
|
+
|
|
894
|
+
def location()
|
|
895
|
+
query.location
|
|
896
|
+
end
|
|
897
|
+
|
|
898
|
+
def photo()
|
|
899
|
+
take_picture
|
|
900
|
+
end
|
|
901
|
+
|
|
902
|
+
def say(text)
|
|
903
|
+
control.speak_text text
|
|
904
|
+
end
|
|
905
|
+
|
|
906
|
+
def say_time()
|
|
907
|
+
control.say_time
|
|
908
|
+
end
|
|
909
|
+
|
|
910
|
+
alias saytime say_time
|
|
911
|
+
|
|
912
|
+
def screen(state=nil)
|
|
913
|
+
control.screen state
|
|
914
|
+
end
|
|
915
|
+
|
|
916
|
+
def screen_on()
|
|
917
|
+
screen :on
|
|
918
|
+
end
|
|
919
|
+
|
|
920
|
+
def screen_off()
|
|
921
|
+
screen :off
|
|
922
|
+
end
|
|
923
|
+
|
|
924
|
+
def take_picture(ftp_src: nil, fileout: '.')
|
|
925
|
+
|
|
926
|
+
screen.on
|
|
927
|
+
r = control.take_picture
|
|
928
|
+
|
|
929
|
+
if ftp_src then
|
|
930
|
+
|
|
931
|
+
# the sleep statement will be replaced in the near future,
|
|
932
|
+
# but it's fine to demonstrate it works
|
|
933
|
+
sleep 8
|
|
934
|
+
|
|
935
|
+
credentials, dir = ftp_src.match(/(ftp:\/\/[^\/]+)\/([^$]+)/).captures
|
|
936
|
+
ftp = MyMediaFTP.new(credentials)
|
|
937
|
+
ftp.cd dir
|
|
938
|
+
filename = ftp.ls.sort_by {|x| x[:ctime]}.last[:name]
|
|
939
|
+
ftp.cp filename, fileout
|
|
940
|
+
|
|
941
|
+
end
|
|
942
|
+
|
|
943
|
+
end
|
|
944
|
+
|
|
945
|
+
def take_photo()
|
|
946
|
+
control.take_photo
|
|
947
|
+
end
|
|
948
|
+
|
|
949
|
+
def torch()
|
|
950
|
+
control.torch
|
|
951
|
+
end
|
|
952
|
+
|
|
953
|
+
def vibrate
|
|
954
|
+
control.vibrate
|
|
955
|
+
end
|
|
546
956
|
|
|
547
957
|
end
|
|
548
958
|
|
|
549
959
|
class TriggerSubscriber < SPSSub
|
|
550
960
|
|
|
551
961
|
def initialize(host: 'sps.home', drb_host: '127.0.0.1')
|
|
552
|
-
@remote = OneDrb::Client.new host: drb_host, port: '5777'
|
|
962
|
+
@remote = OneDrb::Client.new host: drb_host, port: '5777'
|
|
553
963
|
super(host: host)
|
|
554
964
|
end
|
|
555
965
|
|
|
@@ -570,7 +980,7 @@ module RemoteDroid
|
|
|
570
980
|
class ActionSubscriber < SPSSub
|
|
571
981
|
|
|
572
982
|
def initialize(host: 'sps.home', drb_host: '127.0.0.1')
|
|
573
|
-
@remote = OneDrb::Client.new host: drb_host, port: '5777'
|
|
983
|
+
@remote = OneDrb::Client.new host: drb_host, port: '5777'
|
|
574
984
|
super(host: host)
|
|
575
985
|
end
|
|
576
986
|
|
|
@@ -589,5 +999,25 @@ module RemoteDroid
|
|
|
589
999
|
|
|
590
1000
|
end
|
|
591
1001
|
|
|
592
|
-
|
|
1002
|
+
class ResponseSubscriber < SPSSub
|
|
1003
|
+
|
|
1004
|
+
def initialize(host: 'sps.home', drb_host: '127.0.0.1')
|
|
1005
|
+
@remote = OneDrb::Client.new host: drb_host, port: '5777'
|
|
1006
|
+
super(host: host)
|
|
1007
|
+
end
|
|
1008
|
+
|
|
1009
|
+
def subscribe(topic: 'macrodroid/response')
|
|
1010
|
+
|
|
1011
|
+
super(topic: topic) do |msg|
|
|
1012
|
+
|
|
1013
|
+
json, id = msg.split(/:\s+/,2).reverse
|
|
1014
|
+
h = JSON.parse(json, symbolize_names: true)
|
|
1015
|
+
id ||= h.keys.first
|
|
1016
|
+
@remote.update id.to_sym, h
|
|
1017
|
+
|
|
1018
|
+
end
|
|
1019
|
+
|
|
1020
|
+
end
|
|
1021
|
+
|
|
1022
|
+
end
|
|
593
1023
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: remotedroid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Robertson
|
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
|
35
35
|
io3WPRDjULC924M5S8wbrus31v2AUjqFBPvmHr7caf/VHErWypV482xcDhWt1eif
|
|
36
36
|
0G2k2ptozXcBS9odsqGUTb5N
|
|
37
37
|
-----END CERTIFICATE-----
|
|
38
|
-
date: 2020-10-
|
|
38
|
+
date: 2020-10-16 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: onedrb
|
|
@@ -106,7 +106,7 @@ dependencies:
|
|
|
106
106
|
version: '0.9'
|
|
107
107
|
- - ">="
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: 0.9.
|
|
109
|
+
version: 0.9.7
|
|
110
110
|
type: :runtime
|
|
111
111
|
prerelease: false
|
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -116,7 +116,7 @@ dependencies:
|
|
|
116
116
|
version: '0.9'
|
|
117
117
|
- - ">="
|
|
118
118
|
- !ruby/object:Gem::Version
|
|
119
|
-
version: 0.9.
|
|
119
|
+
version: 0.9.7
|
|
120
120
|
description:
|
|
121
121
|
email: james@jamesrobertson.eu
|
|
122
122
|
executables: []
|
metadata.gz.sig
CHANGED
|
Binary file
|