14.07.2017, 10:51
Please help me !
I use the code above to turn the TV on and off but it does not work?
My television is sony bravia 79' X900B.
Does anyone know how to turn it off via HTTP?
----------------
require('socket')
ip = '192.168.1.16'
-- power-on =1, off=0
on = '*SCPOWR0000000000000001\n'
off= '*SCPOWR0000000000000000\n' --SCIRCC0000000000000001
sock=socket.tcp()
sock
ettimeout(1)
a=sock:connect(ip,20060)
if giatri==1 then
b=sock
end(on)
alert('send OK')
else
b=sock
end(off)
alert('send OK')
end
sock:close()
end
------------------------------------------
function check_tv()
require('socket')
sock=socket.tcp()
sock
ettimeout(2)
ip = '192.168.1.16'
cmd = '*SEPOWR################\n'
a=sock:connect(ip,52323)
if a==1 then
b=sock
end(cmd)
if b==24 then
c=sock:receive()
if c=="*SAPOWR0000000000000001" then
alert("tivi đã bật")
return 1
else
alert("tivi đã tắt")
return 0
end
else
alert("Send failed: ")
end
else
alert("connect failed")
end
sock:close()
end
--------------------
Am I wrong?
....
I use the code above to turn the TV on and off but it does not work?
My television is sony bravia 79' X900B.
Does anyone know how to turn it off via HTTP?
----------------
require('socket')
ip = '192.168.1.16'
-- power-on =1, off=0
on = '*SCPOWR0000000000000001\n'
off= '*SCPOWR0000000000000000\n' --SCIRCC0000000000000001
sock=socket.tcp()
sock

a=sock:connect(ip,20060)
if giatri==1 then
b=sock

alert('send OK')
else
b=sock

alert('send OK')
end
sock:close()
end
------------------------------------------
function check_tv()
require('socket')
sock=socket.tcp()
sock

ip = '192.168.1.16'
cmd = '*SEPOWR################\n'
a=sock:connect(ip,52323)
if a==1 then
b=sock

if b==24 then
c=sock:receive()
if c=="*SAPOWR0000000000000001" then
alert("tivi đã bật")
return 1
else
alert("tivi đã tắt")
return 0
end
else
alert("Send failed: ")
end
else
alert("connect failed")
end
sock:close()
end
--------------------
Am I wrong?
