22.09.2016, 19:27
(This post was last modified: 22.09.2016, 19:31 by Erwin van der Zwart.)
Hi,
Here is a script i created a while ago for controlling Samsung.
I never tested this as i have Sony TV (;
Could be i'ts not working but you have a 99% solution that might need some small adjustments in the send (encoded) dataset.
Check documentation i send as URL's in previous post to change it / correct it to the documented format when script does not work like expected.
I have no time to do it for you ..
BR,
Erwin
Here is a script i created a while ago for controlling Samsung.
I never tested this as i have Sony TV (;
Could be i'ts not working but you have a 99% solution that might need some small adjustments in the send (encoded) dataset.
Check documentation i send as URL's in previous post to change it / correct it to the documented format when script does not work like expected.
I have no time to do it for you ..
Code:
require('encdec')
tvip = "100.0.0.123"
myip = "100.0.0.112"
mymac = "00-0c-29-3e-b1-4f"
appstring = "iphone.iapp.samsung"
tvappstring = "iphone.UE55C8000.iapp.samsung"
remotename = "LUA Samsung Remote"
ipencoded = encdec.base64enc(myip)
macencoded = encdec.base64enc(mymac)
-- TCP Send Samsung TV
function sendKey(ip, skey)
host, port = tvip, 55000
socket = require("socket")
client = socket.tcp()
client:settimeout(1)
client:connect(host, port)
messagepart1 = string.char(0x64) .. string.char(0x00) .. string.char(string.len(ipencoded)) .. string.char(0x00) .. ipencoded .. string.char(string.len(macencoded)) .. string.char(0x00) .. macencoded .. string.char(string.len(encdec.base64enc(remotename))) .. string.char(0x00) .. encdec.base64enc(remotename)
part1 = string.char(0x00) .. string.char(string.len(appstring)) .. string.char(0x00) .. appstring .. string.char(string.len(messagepart1)) .. string.char(0x00) .. messagepart1
client:send(part1)
--log(lmcore.strtohex(part1))
result1 = client:receive()
messagepart2 = string.char(0xc8) .. string.char(0x00)
part2 = string.char(0x00) .. string.char(string.len(appstring)) .. string.char(0x00) .. appstring .. string.char(string.len(messagepart2)) .. string.char(0x00) .. messagepart2
client:send(part2)
--log(lmcore.strtohex(part2))
result2 = client:receive()
local messagepart3 = string.char(0x00) .. string.char(0x00) .. string.char(0x00) .. string.char(string.len(encdec.base64enc(skey))) .. string.char(0x00) .. encdec.base64enc(skey)
local part3 = string.char(0x00) .. string.char(string.len(appstring)) .. string.char(0x00) .. appstring .. string.char(string.len(messagepart3)) .. string.char(0x00) .. messagepart3
client:send(part3)
log(lmcore.strtohex(part3))
result3 = client:receive()
client:close()
return result1, result2, result3
end
--Now send the keys as you like, e.g.,
result1, result2, result3 = sendKey(tvip, "KEY_TOOLS")
log(result1, result2, result3)
os.sleep(1)
result1, result2, result3 = sendKey(tvip, "KEY_RIGHT")
log(result1, result2, result3)
os.sleep(1)
result1, result2, result3 = sendKey(tvip, "KEY_DOWN")
log(result1, result2, result3)
os.sleep(1)
result1, result2, result3 = sendKey(tvip, "KEY_RIGHT")
log(result1, result2, result3)
--[[
# Key Reference
# Normal remote keys
#KEY_0
#KEY_1
#KEY_2
#KEY_3
#KEY_4
#KEY_5
#KEY_6
#KEY_7
#KEY_8
#KEY_9
#KEY_UP
#KEY_DOWN
#KEY_LEFT
#KEY_RIGHT
#KEY_MENU
#KEY_PRECH
#KEY_GUIDE
#KEY_INFO
#KEY_RETURN
#KEY_CH_LIST
#KEY_EXIT
#KEY_ENTER
#KEY_SOURCE
#KEY_AD #KEY_PLAY
#KEY_PAUSE
#KEY_MUTE
#KEY_PICTURE_SIZE
#KEY_VOLUP
#KEY_VOLDOWN
#KEY_TOOLS
#KEY_POWEROFF
#KEY_CHUP
#KEY_CHDOWN
#KEY_CONTENTS
#KEY_W_LINK #Media P
#KEY_RSS #Internet
#KEY_MTS #Dual
#KEY_CAPTION #Subt
#KEY_REWIND
#KEY_FF
#KEY_REC
#KEY_STOP
# Bonus buttons not on the normal remote:
#KEY_TV
#Don't work/wrong codes:
#KEY_CONTENT
#KEY_INTERNET
#KEY_PC
#KEY_HDMI1
#KEY_OFF
#KEY_POWER
#KEY_STANDBY
#KEY_DUAL
#KEY_SUBT
#KEY_CHANUP
#KEY_CHAN_UP
#KEY_PROGUP
#KEY_PROG_UP
]]
BR,
Erwin