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.

HelvarNet
#2
Try this script to check communication to HelvarNet. It will send query command every 3 seconds. If this works then status map to group address can be implemented.
Resident script, sleep time = 0. Change 192.168.1.1 to HelvarNet router IP. Change 1.1.2.15 to the address of the device you want to query. You will get raw and parsed replies in Logs tab.

Code:
if not sock then
  ip = '192.168.1.1'

  sock = require('socket').udp()
  sock:setsockname('*', 60001)
  sock:settimeout(1)

  ptime = os.time()

  function parseitem(res, item)
    if item:sub(1, 1) == '@' then
      if item:find('=') then
        local addr, val = unpack(item:split('='))
        res.addr = addr:sub(2)
        res.val = val
      end
    elseif item:find(':') then
      local key, val = unpack(item:split(':'))
      res[ key ] = val
    end
  end

  function parse(data)
    local res = {}

    if not data:find('#') then
      return
    end

    res.type = data:sub(1, 1)
    data = data:sub(2, -2)

    local items = data:split(',')

    for _, item in ipairs(items) do
      parseitem(res, item)
    end

    log(res)
  end
end

data = sock:receive()
if data then
  log(data)
  parse(data)
end

ctime = os.time()
if (ctime - ptime) >= 3 then
  ptime = ctime
  sock:sendto('>V:1,C:152,@1.1.2.15#', ip, 50001)
end
Reply


Messages In This Thread
HelvarNet - by victor.back - 17.04.2020, 07:56
RE: HelvarNet - by admin - 21.04.2020, 14:59
RE: HelvarNet - by victor.back - 07.05.2020, 08:42
RE: HelvarNet - by admin - 07.05.2020, 10:30
RE: HelvarNet - by victor.back - 07.05.2020, 13:21
RE: HelvarNet - by djaval - 16.02.2024, 11:40

Forum Jump: