Logic Machine Forum
Possible help with ZKAccess LUA Library - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Possible help with ZKAccess LUA Library (/showthread.php?tid=2169)



Possible help with ZKAccess LUA Library - SaintJerome - 25.07.2019

I have found an LUA Library for the ZKAccess Door Access panels we use in some of our buildings, but am having some trouble debugging the code to get it running.

Is there someone who could assist (maybe you need this also)? These door access devices are very economical and work really well - getting this library working in the LM (i actually have a cut down version of the LM5 called the 5500NAC in Australia, but works the same) would be brilliant!!

The library is located at https://github.com/vwout/zkaccess-c3-lua and I have added each module as a user library, but the event code doesn't seem to be connecting to the devices at all (can't figure out how to debug libraries).

Any help appreciated.


RE: Possible help with ZKAccess LUA Library - admin - 25.07.2019

Do you have anything in Error log tab? You should also log function return values manually. Usually the first returned value is resulting status and second argument contains error message where applicable.

Code:
C3 = require('user.c3')
res, err = C3.connect("1.1.1.1")
log(res, err)



RE: Possible help with ZKAccess LUA Library - Keough - 29.11.2021

Hi,

I have included all the libraries already. I'm geting the response as below:-
for this

res, err = C3.connect("192.168.1.201")
log(res, err)

door release script testing 29.11.2021 10:31:07
* arg: 1
* bool: false
* arg: 2
* nil

I'm also stuck at the same place, not sure how to debug the library


RE: Possible help with ZKAccess LUA Library - admin - 29.11.2021

If you get false, nil it means that the socket connection was established but there's an error on the protocol level. Check what is the connect callback result:
Code:
local function M_connect_to_C3_cb(size, data_arr)
  log('connect_to_C3_cb', size, data_arr)

  if size == 4 then
    sessionID[1] = data_arr[2] --Second byte is MSB
    sessionID[2] = data_arr[1] --First byte is LSB
    connected = true
  end

  return connected
end



RE: Possible help with ZKAccess LUA Library - Keough - 29.11.2021

(29.11.2021, 08:23)admin Wrote: If you get false, nil it means that the socket connection was established but there's an error on the protocol level. Check what is the connect callback result:
Code:
local function M_connect_to_C3_cb(size, data_arr)
  log('connect_to_C3_cb', size, data_arr)

  if size == 4 then
    sessionID[1] = data_arr[2] --Second byte is MSB
    sessionID[2] = data_arr[1] --First byte is LSB
    connected = true
  end

  return connected
end
Hi, I'm getting the below response

   

Should you want a remote access, I have anydesk installed

Thanks

Lai

(29.11.2021, 13:02)Keough Wrote:
(29.11.2021, 08:23)admin Wrote: If you get false, nil it means that the socket connection was established but there's an error on the protocol level. Check what is the connect callback result:
Code:
local function M_connect_to_C3_cb(size, data_arr)
  log('connect_to_C3_cb', size, data_arr)

  if size == 4 then
    sessionID[1] = data_arr[2] --Second byte is MSB
    sessionID[2] = data_arr[1] --First byte is LSB
    connected = true
  end

  return connected
end
Hi, I'm getting the below response


Should you want a remote access, I have anydesk installed


Btw, I have checked the code that increase the size at below and i have inserted a log viewing.

local function M_get_message_header(data_arr)
  local command = nil
  local size    = 0

  if #data_arr >= 5 then
    if data_arr[1] == consts.C3_MESSAGE_START and
      data_arr[2] == consts.C3_PROTOCOL_VERSION then
      log('M_get_message_header1',command,  size, data_arr)
      command = data_arr[3]
      size    = (data_arr[5] * 255) + data_arr[4]
      log('M_get_message_header2',command,  size, data_arr)
    end
  end
  return command, size
end



   


Thanks

Lai



RE: Possible help with ZKAccess LUA Library - admin - 01.12.2021

If connect succeeded you should get 200 reply code not 201. Unless you have full protocol documentation there's nothing that can be done unfortunately.


RE: Possible help with ZKAccess LUA Library - Keough - 02.12.2021

(01.12.2021, 07:52)admin Wrote: If connect succeeded you should get 200 reply code not 201. Unless you have full protocol documentation there's nothing that can be done unfortunately.

In that case, do you have other brand of door access that is able to integrate with LM?

What about this page?
https://bdragon300.github.io/pyzkaccess/


Thanks

Lai


RE: Possible help with ZKAccess LUA Library - admin - 03.12.2021

The Python library uses SDK provided by the manufacturer. It only runs under Windows. It's should be possible to reverse-engineer it by capturing traffic via Wireshark but that's a complicates task.
For access control you can use Ekey solution with either fingerprints or RFID cards:
https://forum.logicmachine.net/showthread.php?tid=2380