Golang RFID authentication for ps1auth
Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cfg
.gitignore
LICENSE
README.md
beagleboneRobot.go
bom.MD
config.toml-example
dummyRobot.go
dumpdb.go
main.go
rfid-tags.db
server.go

README.md

Client-side RFID authentication (and general access control) for Pumping Station: One

This system is built on a BeagleBone Black and Sparkfun's USB board for RFID readers for hardware, and PS1Auth's server-side RFID authentication on the backend.

Client-side software is written in Go.

Build using go build main.go beagleboneRobot.go dummyRobot.go server.go

Run using ./main -testMode=true

Making things work

The BeagleBone

This software is targeted at Debian Jessie. From the default image, update /etc/apt/sources.list to point at 'jessie' instead of 'wheezy'

sudo apt-get update
sudo apt-get dist-upgrade

This while take a while.

Required Packages

Debian
sudo apt-get install golang

Golang
go get github.com/hybridgroup/gobot
go get github.com/hybridgroup/gobot/platforms/beaglebone
go get github.com/hybridgroup/gobot/platforms/gpio
go get github.com/tarm/goserial go get github.com/BurntSushi/toml

Cloning this repo to your BBB (and building an executable) is the next step. The primary challenges:

  • Launching application on startup of the BBB
  • Enabling non-root access to the GPIO

First, you'll want to create a user to run the service. I created a user 'rfid'

$ sudo adduser rfid

Go ahead and also create a group 'gpio'

$ sudo addgroup gpio

Here's the service file I'm using to launch the application:

[Unit]
Description=Rfid entry service
After=udev.service

[Service]
Type=simple
User=rfid
Group=rfid
ExecStart=$GOPATH/src/github.com/loansindi/ps1rfid/ps1frid
WorkingDirectory=/srv/rfid
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target

Drop this (with appropriate paths) in /etc/systemd/system/rfid.service

The udev rules go in /etc/udev/rules.d/90-gpio.rules :

KERNEL=="gpio*", SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chown -R rfid:gpio /sys/class/gpio'"
KERNEL=="gpio*", SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chown -R rfid:gpio /sys/devices/virtual/gpio/'"
KERNEL=="gpio*", SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chown -R rfid:gpio /sys/devices/bone_capemgr.9'"

This should allow non-elevated access to the GPIO, which is used both for toggling a strike plate and for an internet doorbell.

=======