Class: SiriProxy::Plugin::SamsungRemote
- Inherits:
-
SiriProxy::Plugin
- Object
- SiriProxy::Plugin
- SiriProxy::Plugin::SamsungRemote
- Defined in:
- lib/siriproxy-samsungremote.rb
Constant Summary collapse
- @@appstring =
W hat the iPhone app reports
"iphone..iapp.samsung"
- @@tvappstring =
Might need changing to match your TV type
"iphone.LE40C650.iapp.samsung"
- @@remotename =
What gets reported when it asks for permission/also shows in General->Wireless Remote Control menu
"Ruby Samsung Remote"
- @@know_btns =
[ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'UP', 'DOWN', 'LEFT', 'RIGHT', 'MENU', 'PRECH', 'GUIDE', 'INFO', 'RETURN', 'CH_LIST', 'EXIT', 'ENTER', 'SOURCE', 'AD', 'PLAY', 'PAUSE', 'MUTE', 'PICTURE_SIZE', 'VOLUP', 'VOLDOWN', 'TOOLS', 'POWEROFF', 'CHUP', 'CHDOWN', 'CONTENTS', 'W_LINK', 'RSS', 'MTS', 'CAPTION', 'REWIND', 'FF', 'REC', 'STOP', 'TV', ]
Instance Attribute Summary collapse
-
#myip ⇒ Object
Returns the value of attribute myip.
-
#mymac ⇒ Object
Returns the value of attribute mymac.
-
#port ⇒ Object
Returns the value of attribute port.
-
#tvip ⇒ Object
Returns the value of attribute tvip.
Instance Method Summary collapse
- #close_socket ⇒ Object
-
#initialize(config = {}) ⇒ SamsungRemote
constructor
A new instance of SamsungRemote.
- #press_the(btn) ⇒ Object
- #send_command(command) ⇒ Object
- #send_hanshake ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ SamsungRemote
Returns a new instance of SamsungRemote.
58 59 60 61 62 63 64 |
# File 'lib/siriproxy-samsungremote.rb', line 58 def initialize(config = {}) self.tvip = config["tvip"] self.myip = config["myip"] self.mymac = config["mymac"] self.port = '55000' end |
Instance Attribute Details
#myip ⇒ Object
Returns the value of attribute myip.
5 6 7 |
# File 'lib/siriproxy-samsungremote.rb', line 5 def myip @myip end |
#mymac ⇒ Object
Returns the value of attribute mymac.
5 6 7 |
# File 'lib/siriproxy-samsungremote.rb', line 5 def mymac @mymac end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/siriproxy-samsungremote.rb', line 5 def port @port end |
#tvip ⇒ Object
Returns the value of attribute tvip.
5 6 7 |
# File 'lib/siriproxy-samsungremote.rb', line 5 def tvip @tvip end |
Instance Method Details
#close_socket ⇒ Object
225 226 227 |
# File 'lib/siriproxy-samsungremote.rb', line 225 def close_socket @s.close # Close the socket when done end |
#press_the(btn) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/siriproxy-samsungremote.rb', line 179 def press_the(btn) if @@know_btns.include?(btn.upcase) send_hanshake send_command btn.upcase close_socket say "#{btn} pressed" request_completed #always complete your request! Otherwise the phone will "spin" at the user! else say "I can't find the #{btn} button right now" ask "Try again" request_completed #always complete your request! Otherwise the phone will "spin" at the user! end end |
#send_command(command) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/siriproxy-samsungremote.rb', line 212 def send_command(command) #Send remote key key = "KEY_" + command # say "Sending #{command}" = 0x00.chr + 0x00.chr + 0x00.chr + Base64.encode64(key).length.chr + 0x00.chr + Base64.encode64(key) part3 = 0x00.chr + @@tvappstring.length.chr + 0x00.chr + @@tvappstring + .length.chr + 0x00.chr + @s.send(part3, 0) end |
#send_hanshake ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/siriproxy-samsungremote.rb', line 194 def send_hanshake @s = TCPSocket.open(self.tvip, self.port) ipencoded = Base64.encode64(self.myip) macencoded = Base64.encode64(self.mymac) = 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) part1 = 0x00.chr + @@appstring.length.chr + 0x00.chr + @@appstring + .length.chr + 0x00.chr + @s.send(part1, 0) = 0xc8.chr + 0x00.chr part2 = 0x00.chr + @@appstring.length.chr + 0x00.chr + @@appstring + .length.chr + 0x00.chr + @s.send(part2, 0) end |