Closed haisaco closed 1 month ago
Your code is too long and deeply nested, with few comments.
Are you opening the door to let people in based on events? You are not supposed to do that. If you have registered the user correctly the door should be open by the device, not from your code.
Are you checking what the return value of openDoor
is?
In this wrapper, if an operation fails, a counter is incremented and after a certain number the connection is dropped. This sort of used as a recovery procedure to detect and correct connection loss and device freezes (blame ZKTeco for that).
Are you calling IsConnected to reconnect when the connection is dropped?
However, I agree that openDoor
should not lag if you spam call it. Sadly this is only a wrapper and I don't think there is a bug in these few lines of code.
I never had a device to test with, but I think QR is handled as the user password. I'm not sure what the content of the QR code are either. So:
WRONG, that's what the controller is for. And you don't need ZKTeco's crap software.
First setup a timezone (use id 1 for the default timezone), see the docs here. You just need to create a new User
, set the doors the user can access (See User.Doors
and User.SetDoorsByFlag
, you can do usr.SetDoorsByFlag(255)
to give the user access to all doors) The doors should open now without your code
You must check the result, that method may fail for any reason. (Door already open, door is blocked, power loss, bad sensor, ...)
Any code must cover all the possibilities. You can't code and hope.
If you want extra control you can change your code to only write/delete users who gain/lose accesss. But don't open the door yourself. If you want to open the door yourself, then you don't need the "Access Panel". You just need the QR reader and the door lock, find how you can link them to the computer (i.e. drivers & adapters) and write your own software to replace the controller's logic.
After a while of using the library, I'm encountering some problems. Below is my code:
The above code works normally, but there is a problem that when used to open the door multiple times, the next time will have to wait the entire time of the first time. For example, code 1234 opens the door 10 times after opening the door 3 seconds apart as set. When using code 1235, you will have to wait 10*3=30 seconds for the system to continue opening. i think the problem is await Task.Delay(3000); must not be removed. Do you have any way to optimize this problem? Solve the problem of opening the door multiple times when using 1 code.