This repository contains the code for the live backend used in SAM to collect live sensors data.
The configurations and scripts are generally installed and executed
on Raspberry Pi 4/5 and 0s using the simoc-sam.py script.
The repo contains a simoc-sam.py script used to simplify several
operations. The script will automatically create a venv (virtual
environment), install the dependencies, and run the commands inside
the venv.
You can see the full list of commands with python simoc-sam.py -h,
and you can run them with python simoc-sam.py COMMAND:
initial-setupwill initialize an RPi 0 imagetestwill execute the tests usingpytestinfowill print host info about the network, sensors, and serviceshostswill print information about the other hosts in the network
If you want to manually run some of the scripts inside the venv,
you first have to activate the venv with source venv/bin/activate.
You can execute commands after activating the venv is activated, and
then leave the venv with deactivate.
Since the package is already installed within the venv, you can run
the scripts by doing python -m simoc_sam.scriptname (see the TL;DR
section for an example).
If you are using the simoc-sam.py script, depending on the command,
you might need some additional dependencies that can be installed with:
python3 -m pip install -r requirements.txtAdditionally, for the tmux/ scripts you will need to install tmux with
sudo apt install tmux.
Note: Docker deployment is no longer supported for the time being.
The repository includes a SocketIO bridge and a SocketIO client
(siobridge.py and sioclient.py) that can be used to test the
MQTT->SocketIO conversion. They can both be launched (together with
a Mock Sensor) by running python3 simoc-sam.py run-tmux mqtt.
This is a summary of the commands you need to run everything.
Start everything with:
sudo apt install tmux
python3 simoc-sam.py run-tmuxStart the sensor(s)/client(s):
user@host:path$ source venv/bin/activate
(venv) user@host:path$ python -m simoc_sam.sensors.mocksensor -v
...
(venv) user@host:path$ deactivate
user@host:path$You can run multiple sensors/clients on multiple terminal tabs
(you have to activate the venv in each of them).
Run the tests in the venv with:
python simoc-sam.py test