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.

LM5 and Keba P30
#2
You will need a resident script for receive side and several event scripts for sending requests. Keep in mind that UDP must be enabled separately: Enabled UDP function with DIP-switch DWS1.3 = ON.

Receive script, change 192.168.1.1 to IP address of P30. Since messages are sent via broadcast this script will receive messages that are sent from other scripts. Remove logging once receive is working.
Code:
if not client then
  require('socket')
  require('ifinfo')
  require('json')

  ip = ifinfo().eth0.bcast
  port = 7090

  client = socket.udp()
  client:setoption('broadcast', true)
  client:setoption('reuseaddr', true)
  client:setsockname(ip, port)
  client:settimeout(1)
end

data, src = client:receivefrom()
if data then
  log(data, src)
  
  if src == '192.168.1.1' then
    data = json.pdecode(data)
    log(data)
  end
end

Send script, change data request as needed:
Code:
require('socket')
require('ifinfo')

data = 'i'

ip = ifinfo().eth0.bcast
port = 7090

client = socket.udp()
client:setoption('broadcast', true)
client:setoption('reuseaddr', true)
client:sendto(data, ip, port)
client:close()

Another thing to consider is that reply examples for reports are not valid JSON so you might have to add some extra code for parsing.
Reply


Messages In This Thread
LM5 and Keba P30 - by Rune - 26.01.2019, 21:30
RE: LM5 and Keba P30 - by admin - 28.01.2019, 08:19

Forum Jump: