Skip to content

chez-shanpu/secretary-nfc

Repository files navigation

Secretary nfc

Environment

  • python 3.8.x
  • pipenv
  • nfc reader device

Usage

  1. Setup environment
$ cd {secretary-nfc_root_dir}
$ pipenv install
  1. Regrter device for without sudo
$ sudo vi /etc/udev/rules.d/nfcdev.rules
# you can check the "idVendor" and "idProduct" with `lsusb`
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=={{DEVICE_idVendor}}, ATTRS{idProduct}=={{DEVICE_idProduct}}, GROUP="plugdev"

Also you can get messages by pipenv run python3 -m nfc

  1. Release device from kernel module
$ sudo sh -c 'echo blacklist port100 >> /etc/modprobe.d/blacklist-nfc.conf'
  1. Reboot
$ sudo reboot
  1. prepare config.yaml
$ cp config.sample.yaml config.yaml
# config.yaml
{{ nfc-card id }}: {{ username }}

You can check your nfc-card id by running secretary-nfc, touching the card, and checking the log.

  1. prepare .env
$ cp .env.sample .env
SECRETARY_ENDPOINT=http://localhost/event
  1. Build docker image
$ docker image build . -t secretary-nfc:latest
  1. Run secretary-nfc
$ docker run \
  -v $PWD/config.yaml:/secretary-nfc/config.yaml \
  --device /dev/bus/usb/{{BUS_NUM}}/{DEV_NUM} \
  --env-file .env
  secretary-nfc