This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

LM Lutron telnet listener
#1
hello everyone!!

I made function (with Admin's big help), which will show you what Lutron send by telnet
I have lutron Homework QS

create user libruary "lutron"
Code:
local socket = require("socket")

local user = 'default'
local password = 'default'

function lutron_connect()
    local tcp = assert(socket.tcp())
 tcp:settimeout(31)
    local res, err = tcp:connect('192.168.0.105', 23)
 if res then
   return tcp
 else
   tcp:close()
   return nil, err
 end
end

function lutron_login()
 local tcp, tcp_err = lutron_connect()
 if not tcp then
   return nil,  tcp_err
 end
 tcp:receive(7)
 tcp:send(user..'\r\n')
    tcp:receive(10)
 tcp:send(password..'\r\n')
 local res = tcp:receive(9)
 if res == nil or res == 'bad login' then
   tcp:close()
   return nil, res
 end
 return tcp
end
 
function lutron_receive(tcp)
res, err = tcp:receive()
 if not res then
   tcp:close()
   return nil, err
 end
 return res
end

and resident script
Code:
require('user.lutron')
 
tcp, err = lutron_login()
if not tcp then
 log('no connection to device', err)
end
while tcp do
 res, err = lutron_receive(tcp)
 log(res,err)
   if (res == nil) then
     return
   end
end
Reply


Messages In This Thread
LM Lutron telnet listener - by AEK - 06.10.2016, 13:18
RE: LM Lutron telnet listener - by AEK - 12.10.2016, 12:07
RE: LM Lutron telnet listener - by AEK - 13.10.2016, 06:51
RE: LM Lutron telnet listener - by imprashant - 14.11.2022, 16:13
RE: LM Lutron telnet listener - by admin - 14.11.2022, 16:36
RE: LM Lutron telnet listener - by imprashant - 20.11.2022, 08:13
RE: LM Lutron telnet listener - by admin - 21.11.2022, 08:12
RE: LM Lutron telnet listener - by imprashant - 22.11.2022, 12:05
RE: LM Lutron telnet listener - by admin - 22.11.2022, 12:29
RE: LM Lutron telnet listener - by imprashant - 29.11.2022, 09:50
RE: LM Lutron telnet listener - by admin - 29.11.2022, 10:14
RE: LM Lutron telnet listener - by imprashant - 29.11.2022, 10:24
RE: LM Lutron telnet listener - by admin - 29.11.2022, 10:35
RE: LM Lutron telnet listener - by imprashant - 29.11.2022, 10:49
RE: LM Lutron telnet listener - by admin - 29.11.2022, 11:01
RE: LM Lutron telnet listener - by imprashant - 29.11.2022, 11:14
RE: LM Lutron telnet listener - by admin - 29.11.2022, 11:16
RE: LM Lutron telnet listener - by imprashant - 29.11.2022, 11:31
RE: LM Lutron telnet listener - by imprashant - 20.01.2023, 08:58
RE: LM Lutron telnet listener - by admin - 23.01.2023, 08:09

Forum Jump: