Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
70 changes: 51 additions & 19 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ on:
default: true

jobs:
headless-build:
name: Headless-Rust — Build
headless-package:
name: Headless-Rust — Package arm64 .deb
if: inputs.build-headless
runs-on: ubuntu-latest
defaults:
Expand All @@ -28,27 +28,59 @@ jobs:
steps:
- uses: actions/checkout@v6

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libaravis-dev libudev-dev pkg-config

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install frontend dependencies
run: bun install

# compile embedded web assets into dist/ for rust-embed
- name: Build frontend
run: bun run build
- uses: docker/setup-buildx-action@v4

- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1

# verify release binary compiles cleanly; no artifact upload needed (deploy not required)
- name: Build release binary
run: cargo build --release
# Debian Bookworm cross toolchain (same image as local `bun run package`), layer-cached
- name: Build cross-compilation image
uses: docker/build-push-action@v7
with:
context: headless-rust/packaging
file: headless-rust/packaging/Containerfile
tags: speedcamera-cross:bookworm
load: true
cache-from: type=gha,scope=speedcamera-cross
cache-to: type=gha,mode=max,scope=speedcamera-cross

- name: Cache cargo registry and arm64 build
uses: actions/cache@v5
with:
path: |
headless-rust/target/cross-cache
headless-rust/target/aarch64-unknown-linux-gnu
key: cross-arm64-${{ hashFiles('headless-rust/Cargo.lock', 'headless-rust/packaging/Containerfile') }}
restore-keys: cross-arm64-

- name: Build .deb
env:
VERSION: ${{ inputs.version }}
CONTAINER_ENGINE: docker
SKIP_IMAGE_BUILD: '1'
run: |
if [ -n "$VERSION" ]; then
cargo_version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
tag_version="${VERSION#v}"
if [ "${tag_version%%-*}" != "$cargo_version" ]; then
echo "::error::Tag $VERSION does not match Cargo.toml version $cargo_version. Bump Cargo.toml first."
exit 1
fi
# v1.2.0-canary -> 1.2.0~canary, which dpkg orders before the final 1.2.0
export SPEEDCAMERA_DEB_VERSION="$(printf %s "$tag_version" | tr - '~')"
fi
deb=$(./packaging/build-deb.sh)
mkdir -p ../dist-deb
# stable asset name so releases/latest/download/speedcamera_arm64.deb always resolves
cp "$deb" ../dist-deb/speedcamera_arm64.deb

- name: Upload package artifact
uses: actions/upload-artifact@v7
with:
name: speedcamera-deb
path: dist-deb/speedcamera_arm64.deb
if-no-files-found: error
retention-days: 7

arduino-build:
name: Arduino — Build Firmware
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@ jobs:
permissions:
contents: write
steps:
# only publish arduino firmware binary to release - headless-rust binaries not deployed
- name: Download firmware artifact
uses: actions/download-artifact@v8
with:
name: arduino-firmware
path: artifacts

- name: List artifacts
- name: Download Pi package
uses: actions/download-artifact@v8
with:
name: speedcamera-deb
path: artifacts

# verified by packaging/install.sh and `scripts/pi.sh deploy --release`
- name: Write checksums
working-directory: artifacts
run: |
echo "Artifacts to publish:"
ls -lh artifacts/
sha256sum * > SHA256SUMS
ls -lh
cat SHA256SUMS

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: oven-sh/setup-bun@v2

- name: Install frontend dependencies
run: bun install
run: bun install --frozen-lockfile

- name: TypeScript type-check
run: bun tsc --noEmit
Expand All @@ -32,8 +32,15 @@ jobs:
- name: Build frontend
run: bun run build

# cache-workspaces: rust-cache defaults to ./target, which misses headless-rust/target
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache-workspaces: headless-rust

- name: Run cargo tests
run: cargo test
run: cargo test --locked

# boots the daemon in mock mode: HTTP endpoints, Socket.io RPC, live events
- name: Run integration tests
run: bun run test:integration
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,26 @@ An end-to-end vehicle speed measurement, GigE Vision camera capture, and remote
| --------- | ----------- |
| [**`headless-rust`**](./headless-rust) | **(Recommended)** High-performance single-binary headless daemon and responsive Web UI controller for Raspberry Pi 5 built with Rust (Axum 0.8, Socket.io, native Aravis C FFI, SQLite) and embedded React + Vite frontend. Features IoT-style open AP setup hotspot (`192.168.4.1`) with captive portal redirect, Client Wi-Fi operation mode with scannable connect QR codes, and a dedicated GigE Vision Camera LAN (`192.168.1.100`). |
| [**`arduino`**](./arduino) | Microcontroller firmware (ESP8266 / ESP32) reading dual optical light barriers to calculate vehicle speeds and transmit telemetry over Serial. |
| [**`electronbun`**](./electronbun) | Desktop companion application rewrite built with Electron and Bun. |
| [**`electron`**](./electron) | *(Legacy)* Desktop companion app made with classic Electron. |

The earlier desktop apps (`electron/`, `electronbun/`) were retired in favour of `headless-rust`; they remain in the git history.

---

## Quick Deployment Commands (Raspberry Pi 5)

All deployment and maintenance commands are executed from your development laptop over SSH. The scripts pull the repository and perform all frontend asset builds and native Rust compilation directly on the Raspberry Pi.
Run from your laptop. The Pi installs a prebuilt `.deb` and never compiles anything, so updates also work over its offline hotspot.

```bash
cd headless-rust

# 1. Fresh Pi Setup (Pi connected to Home LAN/Wi-Fi with DHCP)
bun run install:pi pi@raspberrypi.local

# 2. Upgrade Existing Pi (in Client Wi-Fi Mode or Home LAN)
bun run deploy:pi pi@raspberrypi.local
# or when connected to Pi Wi-Fi hotspot during setup:
bun run deploy:pi pi@192.168.4.1
# Install or update (fresh Pi, old git-checkout install, or already packaged)
bun run deploy pi@raspberrypi.local # build the package from this checkout
bun run deploy pi@192.168.4.1 --release # latest GitHub release, via the Pi hotspot

# 3. Complete Cleanup & Reset Network to DHCP
bun run cleanup:pi pi@raspberrypi.local
# Inspect, follow logs, remove
bun run pi status pi@raspberrypi.local
bun run pi logs pi@raspberrypi.local
bun run pi uninstall pi@raspberrypi.local # --purge also deletes data
```

For full documentation on architecture, network onboarding flow, offline/client operation, dependencies, migration guide, and local mock testing, see the [**Headless Rust Documentation**](./headless-rust/README.md).
105 changes: 0 additions & 105 deletions arduino/old/old.cpp

This file was deleted.

Loading
Loading