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.

TCP Socket Connection for Legrand
#30
(27.06.2022, 12:15)admin Wrote: You need a separate socket connection for commands. You also need to send another init sequence: *99*0##.
This example should control light point 11 by converting 0..100% value to 0..10. There's some extra logging to check if the message flow is correct. Remove it when the script is working properly.
Code:
value = event.getvalue()
value = math.ceil(value / 10)

cmd = '*1*' .. value .. '*11##'

sock = require('socket').tcp()
sock:settimeout(1)

res, err = sock:connect('192.168.1.247', 20000)

if res then
  sock:send('*99*0##')
 
  res, err = sock:receive(6) -- receive ACK
  log('receive 1', res, err)

  res, err = sock:send(cmd)
  log('send', res, err)

  res, err = sock:receive(6) -- receive result ACK/NACK
  log('receive 2', res, err)
else
  log('connect failed', err)
end

sock:close()

Works perfectly!

Thank you very much for the help!
Reply


Messages In This Thread
RE: TCP Socket Connection for Legrand - by a455115 - 28.06.2022, 07:44

Forum Jump: