FabOMatic

Backend for Fab-O-Matic RFID boards


Keywords
fab-o-matic, fablab, mqtt, python, raspberry-pi, sqlalchemy
License
MIT
Install
pip install FabOMatic==0.5.0

Documentation

rfid-backend

Build & Test status Python package

Python dependencies

  • toml (for configuration file)
  • paho.mqtt (for MQTT client)
  • SQLAlchemy (for database interface)
  • colorlog (for nicer logs in the console)

Backend runtime requirements

  • An external MQTT Broker. Mosquitto has been used for testing.
  • A database engine. SQLAlchemy supports several, but this has been tested with SQLite only (so far)

Installation instructions

  • Install prerequisites (python 3.10+, mosquitto, pip)
  • Install from test pypi repository
pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple rfid_backend_FABLAB_BG
  • Change defaults in conf/settings.toml (see below)
  • After installation login with default admin email in settings file and "admin" password.
  • Setup backup strategy for SQLDB file.

Configuration file

  • See file conf\settings.toml to setup MQTT server, database connections, SMTP for "forgot password" email. Example below
[database]
url = "sqlite:///machines.sqldb"
name = "fablab"

[MQTT]
broker = "127.0.0.1"
port = 1883
client_id = "backend"
topic = "machine/"        # root topic. Subtopics will be /machine/<ID> will be subscribed
reply_subtopic = "/reply"  # appended to the machine topics for replies by backend. E.g. machine/1/reply
stats_topic = "stats/"

[web]
secret_key = "some_long_hex_string_1234gs"  # Used for encryption
default_admin_email = "admin@fablag.org"    # Used for initial login

[email]
server = "smtp.google.com"
port = 587
use_tls = true
username = ""
password = ""

Dev environment settings

  • Developped with VSCode
  • Create a python venv with Python >=3.10
  • Test settings are into tests\test_settings.toml file, to run tests from root folder (or Terminal)
pytest -v
  • VSCode extensions : Python, Black extension for automatic code formatting
  • How to run the server from Terminal (from root folder)
pip install -e . 
python ./run.py
pip install --upgrade build
pip install --upgrade twine

To update distribution

py -m build
py -m twine upload --repository testpypi dist/*