1
0
Fork 0
Go to file
Alexander Böhm 703bb1b48c Refactoring 2024-01-05 16:53:27 +01:00
.cargo Added cross compile configuration 2024-01-05 15:02:36 +01:00
.config init 2023-04-21 19:10:17 +02:00
src Refactoring 2024-01-05 16:53:27 +01:00
.env init 2023-04-21 19:10:17 +02:00
.gitignore init 2023-04-21 19:10:17 +02:00
Cargo.lock Replaced executor with tokio 2024-01-05 01:14:41 +01:00
Cargo.toml Enabled stripping for release builds 2024-01-05 15:02:12 +01:00
Makefile init 2023-04-23 02:34:29 +02:00
README.md Add install instruction 2024-01-05 16:30:28 +01:00
rust-toolchain Added cross compile configuration 2024-01-05 15:02:36 +01:00
shell.nix init 2023-04-23 02:34:29 +02:00

README.md

Spaceapi Tuerpi

Feeding our SpaceAPI with Data from our entrance door.

Setup

Please change DOOR_PIN accordingly.

DOOR_PIN defaults to a closed door, when HIGH.

You need to provide the environment variables SPACEAPI_URL and API_KEY.

Build

Install stable version of rust and run a regular cargo build:

cargo build

Cross compile

Install arm toolchain and libmusl for static linked binaries:

apt-get install gcc-arm-linux-gnueabihf musl-dev musl-tools

Build the application for raspberry pi:

cargo build --target=armv7-unknown-linux-musleabihf

Install

Place the build pi binary under /usr/local/bin/spaceapi-dezentrale-pi-client

install -m 755 -o root -g root \
    target/release/pi \
    /usr/local/bin/spaceapi-tuerpi

Configure the spaceapi systemd service by placing the service description under /etc/systemd/system/spaceapi.service:

[Unit]
Description=SpaceAPI tuerpi client
After=network.target

[Service]
Type=simple
Restart=always
EnvironmentFile=/etc/spaceapi-tuerpi.env 
ExecStart=/usr/local/bin/spaceapi-tuerpi

[Install]
WantedBy=multi-user.target

Place the environment configuration with URL and API-Key under /etc/spaceapi-tuerpi.env:

SPACEAPI_URL=<your SpaceAPI server endpoint>
API_KEY=<your secret API key>

Ensure the /etc/spaceapi-tuerpi.env can be read only by root by executing:

chmod 600 /etc/spaceapi-tuerpi.env
chown root:root /etc/spaceapi-tuerpi.env

Apply changes to systemd to enable and start the service

systemctl daemon-reload
systemctl enable --now spaceapi