Code Monkey home page Code Monkey logo

uhppote-simulator's Introduction

build

uhppoted implements a set of cross-platform building blocks for access control systems based on the UHPPOTE UT0311-L0x TCP/IP Wiegand access control boards. Currently available components include:

The components supplement the manufacturer supplied application which is 'Windows-only' and provides limited support for integration with other systems.

FYA, after much discussion it has been decided that uhppoted is pronounced u-hop-id-ay-d (juː hɒp ɪt eɪd).

Operating systems

Supported operating systems:

  • Linux
  • MacOS
  • Windows
  • ARM and ARM7 (e.g. RaspberryPi)

Language Bindings

The primary development language for this repository is Go, but code generated native bindings for the following languages also exist:

shared-lib/dylib/DLL

uhppoted-dll implements a shared-lib/DLL for interop with languages other than Go. The implementation includes bindings to:

  • C
  • C++
  • C#
  • Python
  • Clozure Common Lisp

3rd party integrations

Compatible Hardware

As per this issue [Question] Compatible Hardware, UHPPOTE appears to be a specific branding (or distributor) for the access control boards manufactured by Shenzhen Wiegand Industrial Co., Ltd.

The software in this repository has been tested and is known to work with these specific boards:

Source Item
Amazon UHPPOTE Professional Wiegand 26-40 Bit TCP IP Network Access Control Board with Software For 4 Door 4 Reader
AliExpress TCP/IP RFID ACCESS CONTROL SYSTEM Wiegand 26

Firmware versions

Version Notes
6.56 Minimum firmware version (cf. carbonsphere/UHPPOTE
6.62 Lowest firmware version in use
8.92 Latest tested firmware version

Notes:

  1. Firmware v6.62 sends anomalous listen events with 0x19 as the start of message identifier. This appears to have been fixed in later firmware versions but patches to support these events are included in:

Readers

Almost any reader with a Wiegand-26 interface should probably work (there have been reports of offbrand readers that don't) but the readers below are in active use:

Reader Notes
HID ProxPoint Plus 6500 Old stock and/or refurbished readers are often available on ebay
IKeys barcode and QR code scanner Ref. Put Card - Date with Time
Newland FM430L barcode and QR code scanner Ref. Put Card - Date with Time

Release Notes

Current Release

v0.8.8 - 2024-03-28

  1. Added uhppoted-app-home-assistant experimental Home Assistant integration.
  2. restore-default-parameters function across all subprojects.
  3. Added public Docker images for uhppote-simulator, uhppoted-rest, uhppoted-mqtt, and uhppoted-httpd to ghcr.io.
  4. Bumped Go version to 1.22.
  5. Reworked uhppoted-app-wild-apricot member/group resolution logic.

Modules

Module Description
uhppote-core core library, implements the UP interface to UT0311-L0x controllers
uhppoted-lib common utility function library
uhppote-simulator UT0311-L04 simulator for development use
uhppote-cli command line interface
uhppoted-rest daemon/service with REST API for remote access to UT0311-L0x controllers
uhppoted-mqtt daemon/service with MQTT endpoint for remote access to UT0311-L0x controllers
uhppoted-app-s3 cron'able utility to download/upload access control lists from/to AWS S3
uhppoted-app-sheets cron'able utility to download/upload access control lists from/to Google Sheets
uhppoted-app-db cron'able utility to download/upload access control lists from/to a SQL DB
uhppoted-app-wild-apricot cron'able utility to manage access control lists from Wild Apricot
uhppoted-app-home-assistant Home Assistant custom component
node-red-contrib-uhppoted NodeJS nodes for Node-RED low code environment
uhppoted-nodejs Standalone NodeJS module
uhppoted-python Standalone Python package for PyPI
uhppoted-dll shared-lib/DLL for cross-language interop
uhppoted-codegen Model based code generator for native language bindings
uhppoted-tunnel UDP tunnel for remote access

Integrations

Module Description
uhppoted-app-db cron'able utility to download/upload access control lists from/to a SQL DB
uhppoted-app-s3 cron'able utility to download/upload access control lists from/to AWS S3
uhppoted-app-sheets cron'able utility to download/upload access control lists from/to Google Sheets
uhppoted-app-wild-apricot cron'able utility to manage access control lists from/t Wild Apricot
uhppoted-app-home-assistant Home Assistant custom component
node-red-contrib-uhppoted NodeJS nodes for Node-RED low code environment
kBrausew/ioBroker.wiegand-tcpip ioBroker

UI

Module Description
uhppote-cli Command line interface
uhppoted-httpd HTML browser interface

Installation

Binaries for Linux, Windows, MacOS and Raspbian/ARM7 are distributed in the tarball for each release. To install the binaries, download and extract the tarball to a directory of your choice.

The NodeRED, NodeJS and Python packages are installable from the public repositories:

Building from source

uhppoted is the parent project for the individual components which are referenced as git submodules - to clone the entire source tree:

git clone --recurse-submodules https://github.com/uhppoted/uhppoted.git

The supplied Makefile has targets to build binaries for all the supported operating systems:

make build

or

make release

To pull upstream changes for all submodules:

git submodule update --remote

Donations

If you like the project and you really want to 🙂:

References and Related Projects

  1. carbonsphere/UHPPOTE PHP
  2. carbonsphere/DoorControl PHP
  3. andrewvaughan/uhppote-rfid Python
  4. tachoknight/uhppote-tools: Go
  5. jjhuff/uhppote-go: Go
  6. pawl/Chinese-RFID-Access-Control-Library
  7. Dallas Makerspace:Reverse Engineering RFID Reader
  8. wemakerspace/wiegand-daemon
  9. wemakerspace/weigeng-js
  10. realashleybailey/DoorControl
  11. kBrausew/ioBroker.wiegand-tcpip
  12. TCP/IP Wiegand Access Controller (Zutrittskontrolle)
  13. YouTube: UHPPOTE 2 door basic set-up
  14. wouterdebie/uhppote-rs

uhppote-simulator's People

Contributors

twystd avatar uhppoted avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ardelldou

uhppote-simulator's Issues

Possible issue with time profiles

Hello! I'm not sure if this is an issue with uhppote-simulator, or if I'm doing something wrong - any guidance you can provide would be greatly appreciated.


Background

I'm working on a Python tool (using the uhppote-dll Python bindings) to allow my local makerspace's membership tooling to automatically sync door access to our Uhppote access control boards. I'm in the process of finishing the tool, and am working to expand testing. However, I appear to either be misunderstanding how time profiles work, or have disocvered a bug with uhppote-simulator, which I am using for initial testing in lieu of physical hardware.

Scenario

As part of testing, I stand up a simulator instance and expose a quick method to perform simulated card swipes. I then take the system through the process of syncing several test users/cards, and verifying that they have access only at the appropriate times. Between each test, I use the set-time function to change the simulator's time, then check to see if access is allowed or denied, based on the card's configured access.

Issue

Time profiles do not appear to be working correctly. When setting access to 1 (24/7) for a door, the card(s) work correctly. When setting to a defined time profile, access is variably granted/denied both outside and within the defined ranges of the profile. I've tried converting some/all times to UTC, which does not seem to help.

At time of last testing (9AM Eastern on October 14), test 1 for card 2 succeeds (access is denied prior to the time profile range), but test 2 fails (access is denied during the time profile range). Earlier, both test 1 and test 2 failed (i.e access granted before profile range, and denied during). My current best guess is that the simulator may not be respecting the time set by set-time when calculating time profile accesses. As a quick test, I changed the ranges below to encompass my current time, and the profile suddenly worked.

Issue encountered on Linux x86_64 (PopOS/Ubuntu 22.04 LTS).

Steps to Reproduce

I whipped up the following scripts to quickly reproduce the issue, using uhppote-simulator and uhppote-cli. This is essentially part of my Python tool testing, rewritten for Bash/uhppote-cli.

First, create test-cli.conf with the following contents:

UT0311-L0x.123456789.name = Test
UT0311-L0x.123456789.address = 127.0.0.1:60000
UT0311-L0x.123456789.door.1 = Front Door
UT0311-L0x.123456789.door.2 = Lobby
UT0311-L0x.123456789.door.3 = IT Room
UT0311-L0x.123456789.door.4 = Back Door
UT0311-L0x.123456789.timezone = UTC

Next, create test-cli.sh with the following contents.

curl -X POST http://127.0.0.1:8000/uhppote/simulator -H 'Content-Type: application/json' -d '{"device-id": 123456789, "device-type": "UT0311-L04", "compressed": false}'

# set profiles for "junior members" - 5-10 weekends, 12-5 weekends
./uhppote-cli --config test_cli.conf set-time-profile 123456789 3 1970-01-01:2099-12-31 Sat,Sun 11:45-17:15
./uhppote-cli --config test_cli.conf set-time-profile 123456789 2 1970-01-01:2099-12-31 Mon,Tue,Wed,Thu,Fri 16:45-22:15 3

# set cards, one full access, one "junior"
./uhppote-cli --config test_cli.conf put-card 123456789 00154321 1970-01-01 2099-12-31 1,2,4
./uhppote-cli --config test_cli.conf put-card 123456789 00112345 1970-01-01 2099-12-31 1:2,2:2,4:2

# set time and check access

# test 1 - door 1 prior to time on Monday
# card 1 should have access, card 2 should not
./uhppote-cli --config test_cli.conf set-time 123456789 '2022-10-03 16:35:00'  # monday
out=$(curl -s -X POST http://127.0.0.1:8000/uhppote/simulator/123456789/swipe -H 'Content-Type: application/json' -d '{"door": 1, "card-number": 154321}')
if [ "$out" != '{"access-granted":true,"message":"Access granted"}' ]; then
	  echo "card 154321 test 1 - access not allowed when it should be granted!"
	  echo "$out"
else
	  echo "card 154321 test 1 - access OK (granted)!"
fi

out=$(curl -s -X POST http://127.0.0.1:8000/uhppote/simulator/123456789/swipe -H 'Content-Type: application/json' -d '{"door": 1, "card-number": 112345}')
if [ "$out" != '{"access-granted":false,"message":"Access denied"}' ]; then
	  echo "card 112345 test 1 - access allowed when it should be denied!"
	  echo "$out"
else
	  echo "card 112345 test 1 - access OK (denied)!"
fi


# test 2 - door 1 during time on Monday
# both cards should have access
./uhppote-cli --config test_cli.conf set-time 123456789 '2021-10-03 16:55:00'
for card in 154321 112345; do
	  out=$(curl -s -X POST http://127.0.0.1:8000/uhppote/simulator/123456789/swipe -H 'Content-Type: application/json' -d "{\"door\": 1, \"card-number\": $card}")
	  if [ "$out" != '{"access-granted":true,"message":"Access granted"}' ]; then
	  	  echo "card $card test 2 - access not allowed when it should be granted!"
	  	  echo "$out"
	  else
	  	  echo "card $card test 2 - access OK (granted)!"
	  fi
done


echo ""
echo "current time is: $(./uhppote-cli --config test_cli.conf get-time 123456789)"
echo "card 1 data is: $(./uhppote-cli --config test_cli.conf get-card 123456789 112345)"
echo "card 2 data is: $(./uhppote-cli --config test_cli.conf get-card 123456789 154321)"
echo "profile 2 is: $(./uhppote-cli --config test_cli.conf get-time-profile 123456789 2)"
echo "profile 3 is: $(./uhppote-cli --config test_cli.conf get-time-profile 123456789 3)"

Next, create run-sim.sh with the following contents. This assumes that uhppote-simulator is available in the same directory. The fix in this file is related to another bug - I'll file a separate issue on that.

# fix for simulator refusing to startup when a config file is present
if [ -f "/tmp/123456789.json" ]; then
	  rm "/tmp/123456789.json"
fi
./uhppote-simulator --bind 127.0.0.1:60000 --rest 127.0.0.1:8000 --devices /tmp/

Finally, run run-sim.sh and test-cli.sh in seperate terminal windows. Be sure to run run-sim.sh first, and leave it running until done with test-cli.sh (CTRL+C to exit when done with it)!

Sample output:

123456789: time profile 3 created
123456789: time profile 2 created
123456789 154321 true
123456789 112345 true
123456789  2022-10-03 16:35:00
card 154321 test 1 - access OK (granted)!
card 112345 test 1 - access OK (denied)!
123456789  2021-10-03 16:55:00
card 154321 test 2 - access OK (granted)!
card 112345 test 2 - access not allowed when it should be granted!
{"access-granted":false,"message":"Access denied"}

current time is: 123456789  2021-10-03 16:55:00
card 1 data is: 123456789  112345   1970-01-01 2099-12-31 2 2 N 2
card 2 data is: 123456789  154321   1970-01-01 2099-12-31 Y Y N Y
profile 2 is: 123456789  2 1970-01-01:2099-12-31 Mon,Tue,Wed,Thurs,Fri 16:45-22:15 3
profile 3 is: 123456789  3 1970-01-01:2099-12-31 Sat,Sun 11:45-17:15 0

Again, not sure if this is an issue with the simulator, or if I'm missing something with the time profiles. I have a physical board and am planning to test with that as well, but I am currently waiting on some parts to get it hooked up.

Thank you in advance for your assistance!

Simulator hangs on startup when existing device file is present

As mentioned in #5.


Issue

When running uhppote-simulator, the simulator hangs when attempting to load config files from a previous run. Neither the REST API or any simulated controllers can be contacted.

Issue encountered on Linux x86_64 (PopOS/Ubuntu 22.04 LTS).

Steps to Reproduce

In a terminal window, run the following to start a uhppote-simulator instance.

./uhppote-simulator --bind 127.0.0.1:60000 --rest 127.0.0.1:8000 --devices /tmp/

In another terminal window, run the following to generate a controller config. (EDIT: Fixed duplicate command)

curl -X POST http://127.0.0.1:8000/uhppote/simulator -H 'Content-Type: application/json' -d '{"device-id": 123456789, "device-type": "UT0311-L04", "compressed": false}'

In the first terminal window, stop and rerun the uhppote-simulator command. It will hang similar to the following. The make targets were setup to make testing easier: simulator checks for and removes a config file prior to running the simulator, while sim does not, just attempts to run the simulator.

amprim@pop-os:~/Projects/access_control$ make simulator
mkdir -p /tmp/devices
./uhppote-simulator --bind 127.0.0.1:60000 --rest 127.0.0.1:8000 --devices /tmp/devices
   ... loading devices from '/tmp/devices'
   ... bound to address '127.0.0.1:60000'

^CFailed to read from UDP socket [read udp 127.0.0.1:60000: use of closed network connection]
make: *** [Makefile:7: simulator] Error 1

amprim@pop-os:~/Projects/access_control$ make sim
./uhppote-simulator --bind 127.0.0.1:60000 --rest 127.0.0.1:8000 --devices /tmp/devices
   ... loading devices from '/tmp/devices'

As you can see, something prevents the simulator from reaching the point of binding to the --bind address.


Thank you in advance for your assistance!

the parameter -rest 8000 dosn't work

the error message is:
listen tcp: address 8443: missing port in address

if tested with and without started UHPPOTED-REST & port 8000 and 8443, message is the always same

docker::uhppote-simulator with --net=host not replying to commands

With the docker version of uhppote-simulator, on Ubuntu 20.10:

docker run --interactive --net=host --name simulator --rm simulator

./bin/uhppote-cli --debug set-listener 405419896 192.168.1.100:60001
... request
... 00000000 17 90 00 00 78 37 2a 18 c0 a8 01 64 61 ea 00 00 |....x7*....da...|
... 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
... 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
... 00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
...
... sent 64 bytes to 155.138.151.255:60000

ERROR: read udp 155.138.150.146:35544: i/o timeout

The simulator does not receive the command.

docker::uhppote-simulator with --net=host not broadcasting events

With the docker version of uhppote-simulator, on Ubuntu 20.10:

  1. Start the simulator docker container:

docker run --interactive --net=host --name simulator --rm simulator

  1. Set the simulator listen address and start the CLI listener:

./bin/uhppote-cli --debug --broadcast 0.0.0.0:60000 set-listener 405419896 155.138.151.255:60001
./bin/uhppote-cli --debug listen

  1. Simulate a swipe:

make swipe

The simulator broadcasts a swipe event but the CLI does not receive it:

...
... sent 64 bytes to 155.138.151.255:60001
... 00000000 17 20 00 00 78 37 2a 18 46 00 00 00 01 00 03 01 |. ..x7*.F.......|
... 00000010 02 00 01 00 20 20 12 14 12 02 17 06 00 00 00 00 |.... ..........|
... 00000020 00 00 00 00 00 12 02 17 00 00 00 00 00 00 00 00 |................|
... 00000030 00 00 00 20 12 14 00 00 00 00 00 00 00 00 00 00 |... ............|
...

./bin/uhppote-cli --debug listen
Listening...
... listening

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.