siriproxy-samsungremote 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/SiriProxy-SamsungRemote.gemspec +1 -1
- data/VERSION +1 -1
- data/lib/siriproxy-samsungremote.rb +169 -9
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -7,7 +7,53 @@ class SiriProxy::Plugin::SamsungRemote < SiriProxy::Plugin
|
|
7
7
|
@@appstring = "iphone..iapp.samsung" #W hat the iPhone app reports
|
8
8
|
@@tvappstring = "iphone.LE40C650.iapp.samsung" # Might need changing to match your TV type
|
9
9
|
@@remotename = "Ruby Samsung Remote" # What gets reported when it asks for permission/also shows in General->Wireless Remote Control menu
|
10
|
-
|
10
|
+
|
11
|
+
@@know_btns = [
|
12
|
+
'0',
|
13
|
+
'1',
|
14
|
+
'2',
|
15
|
+
'3',
|
16
|
+
'4',
|
17
|
+
'5',
|
18
|
+
'6',
|
19
|
+
'7',
|
20
|
+
'8',
|
21
|
+
'9',
|
22
|
+
'UP',
|
23
|
+
'DOWN',
|
24
|
+
'LEFT',
|
25
|
+
'RIGHT',
|
26
|
+
'MENU',
|
27
|
+
'PRECH',
|
28
|
+
'GUIDE',
|
29
|
+
'INFO',
|
30
|
+
'RETURN',
|
31
|
+
'CH_LIST',
|
32
|
+
'EXIT',
|
33
|
+
'ENTER',
|
34
|
+
'SOURCE',
|
35
|
+
'AD',
|
36
|
+
'PLAY',
|
37
|
+
'PAUSE',
|
38
|
+
'MUTE',
|
39
|
+
'PICTURE_SIZE',
|
40
|
+
'VOLUP',
|
41
|
+
'VOLDOWN',
|
42
|
+
'TOOLS',
|
43
|
+
'POWEROFF',
|
44
|
+
'CHUP',
|
45
|
+
'CHDOWN',
|
46
|
+
'CONTENTS',
|
47
|
+
'W_LINK',
|
48
|
+
'RSS',
|
49
|
+
'MTS',
|
50
|
+
'CAPTION',
|
51
|
+
'REWIND',
|
52
|
+
'FF',
|
53
|
+
'REC',
|
54
|
+
'STOP',
|
55
|
+
'TV',
|
56
|
+
]
|
11
57
|
|
12
58
|
def initialize(config = {})
|
13
59
|
|
@@ -35,14 +81,118 @@ class SiriProxy::Plugin::SamsungRemote < SiriProxy::Plugin
|
|
35
81
|
|
36
82
|
listen_for(/test command/i) do
|
37
83
|
say "About to test"
|
38
|
-
|
84
|
+
send_hanshake
|
85
|
+
send_command "MUTE"
|
86
|
+
close_socket
|
39
87
|
say "Command sent"
|
40
88
|
request_completed #always complete your request! Otherwise the phone will "spin" at the user!
|
41
89
|
|
42
90
|
end
|
43
91
|
|
44
|
-
|
45
|
-
|
92
|
+
listen_for(/can you turn the sound (up|down)/i) do |dir|
|
93
|
+
send_hanshake
|
94
|
+
if dir == 'up'
|
95
|
+
command = 'VOLUP'
|
96
|
+
elsif dir == 'down'
|
97
|
+
command = 'VOLDOWN'
|
98
|
+
end
|
99
|
+
send_command command
|
100
|
+
begin
|
101
|
+
keepgoing = ask "Is that ok?"
|
102
|
+
keepgoing.strip!
|
103
|
+
if keepgoing == "No" or keepgoing == "Nope" or keepgoing == "Not yet" or keepgoing == "Keep going" or keepgoing == "That isn't good" or keepgoing == "That's not good" then
|
104
|
+
keepgoing = "1"
|
105
|
+
send_command command
|
106
|
+
elsif keepgoing == /too quiet/i or keepgoing == /too loud/i
|
107
|
+
keepgoing = "1"
|
108
|
+
command = command == "VOLUP" ? "VOLDOWN" : "VOLUP"
|
109
|
+
send_command command
|
110
|
+
else
|
111
|
+
keepgoing = "0"
|
112
|
+
say "Ok. I'll leave it there."
|
113
|
+
end
|
114
|
+
end while keepgoing == "1"
|
115
|
+
|
116
|
+
close_socket
|
117
|
+
request_completed
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
listen_for(/launch the iplayer/i) do
|
122
|
+
send_hanshake
|
123
|
+
|
124
|
+
send_command "RSS"
|
125
|
+
sleep 2
|
126
|
+
send_command "RIGHT"
|
127
|
+
sleep 1
|
128
|
+
send_command "ENTER"
|
129
|
+
|
130
|
+
close_socket
|
131
|
+
request_completed
|
132
|
+
end
|
133
|
+
|
134
|
+
listen_for(/exit the iplayer/i) do
|
135
|
+
send_hanshake
|
136
|
+
|
137
|
+
send_command "EXIT"
|
138
|
+
|
139
|
+
close_socket
|
140
|
+
request_completed
|
141
|
+
end
|
142
|
+
|
143
|
+
listen_for(/go (left|right|up|down)/i) do |dir|
|
144
|
+
posdir = ["left", "right", "up", "down"]
|
145
|
+
if posdir.include?(dir)
|
146
|
+
send_hanshake
|
147
|
+
send_command dir.upcase
|
148
|
+
close_socket
|
149
|
+
else
|
150
|
+
say "I can't go that way"
|
151
|
+
end
|
152
|
+
request_completed
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
listen_for(/can you turn the telly off please/i) do
|
157
|
+
|
158
|
+
sure = ask "Are you sure?"
|
159
|
+
sure.strip!
|
160
|
+
if sure == "Yes" or sure == "Yes please"
|
161
|
+
send_hanshake
|
162
|
+
|
163
|
+
send_command "POWEROFF"
|
164
|
+
|
165
|
+
close_socket
|
166
|
+
say "Ok, I've turned it off. You'll need to turn it on yourself if you want me to do anything else with the telly."
|
167
|
+
else
|
168
|
+
say "Ok, I'll leave it on for now then"
|
169
|
+
end
|
170
|
+
|
171
|
+
request_completed
|
172
|
+
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
listen_for(/press the (.*) button/i) { |btn| press_the(btn) }
|
177
|
+
|
178
|
+
|
179
|
+
def press_the(btn)
|
180
|
+
if @@know_btns.include?(btn.upcase)
|
181
|
+
send_hanshake
|
182
|
+
send_command btn.upcase
|
183
|
+
close_socket
|
184
|
+
say "#{btn} pressed"
|
185
|
+
request_completed #always complete your request! Otherwise the phone will "spin" at the user!
|
186
|
+
else
|
187
|
+
say "I can't find the #{btn} button right now"
|
188
|
+
ask "Try again"
|
189
|
+
request_completed #always complete your request! Otherwise the phone will "spin" at the user!
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
def send_hanshake
|
195
|
+
@s = TCPSocket.open(self.tvip, self.port)
|
46
196
|
|
47
197
|
ipencoded = Base64.encode64(self.myip)
|
48
198
|
macencoded = Base64.encode64(self.mymac)
|
@@ -50,22 +200,32 @@ class SiriProxy::Plugin::SamsungRemote < SiriProxy::Plugin
|
|
50
200
|
messagepart1 = 0x64.chr + 0x00.chr + ipencoded.length.chr + 0x00.chr + ipencoded + macencoded.length.chr + 0x00.chr + macencoded + Base64.encode64(@@remotename).length.chr + 0x00.chr + Base64.encode64(@@remotename)
|
51
201
|
part1 = 0x00.chr + @@appstring.length.chr + 0x00.chr + @@appstring + messagepart1.length.chr + 0x00.chr + messagepart1
|
52
202
|
|
53
|
-
s.send(part1, 0)
|
203
|
+
@s.send(part1, 0)
|
54
204
|
|
55
205
|
messagepart2 = 0xc8.chr + 0x00.chr
|
56
206
|
part2 = 0x00.chr + @@appstring.length.chr + 0x00.chr + @@appstring + messagepart2.length.chr + 0x00.chr + messagepart2
|
57
207
|
|
58
|
-
s.send(part2, 0)
|
208
|
+
@s.send(part2, 0)
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
def send_command(command)
|
59
213
|
|
60
214
|
#Send remote key
|
61
215
|
key = "KEY_" + command
|
62
|
-
say "Sending #{command}"
|
216
|
+
# say "Sending #{command}"
|
63
217
|
messagepart3 = 0x00.chr + 0x00.chr + 0x00.chr + Base64.encode64(key).length.chr + 0x00.chr + Base64.encode64(key)
|
64
218
|
part3 = 0x00.chr + @@tvappstring.length.chr + 0x00.chr + @@tvappstring + messagepart3.length.chr + 0x00.chr + messagepart3
|
65
219
|
|
66
|
-
s.send(part3, 0)
|
220
|
+
@s.send(part3, 0)
|
67
221
|
|
68
|
-
|
222
|
+
|
69
223
|
end
|
70
224
|
|
225
|
+
def close_socket
|
226
|
+
@s.close # Close the socket when done
|
227
|
+
end
|
228
|
+
|
229
|
+
|
230
|
+
|
71
231
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: siriproxy-samsungremote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Steve Kingsley
|
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
hash:
|
93
|
+
hash: 2765555781884527161
|
94
94
|
segments:
|
95
95
|
- 0
|
96
96
|
version: "0"
|