This commit adds the complete Dangerous Pi web management interface with all MVP features implemented and tested locally. ## New Features ### Backend (Python + FastAPI) - Complete FastAPI backend with async support - 40+ API endpoints (Health, PM3, WiFi, Updates, UPS, BLE, Plugins) - 6 managers: Session, WiFi, Update, UPS, BLE, Plugin - SQLite database with sessions, config, history, crash reports - Server-Sent Events (SSE) for real-time notifications - Mock PM3 worker for development without hardware ### WiFi Manager - Interface detection (USB vs built-in) - Network scanning with signal strength - Mode switching (AP/Client/Dual/Auto/Off) - Network connection with password support - Hidden SSID and saved networks support - Static IP and DHCP configuration - 10 WiFi API endpoints ### Update Manager - GitHub releases API integration - Automatic periodic update checks - Semantic version comparison - Update download with progress tracking - SHA256 checksum verification - Automatic installation with backup and rollback - PM3 client rebuild after updates - 6 Update API endpoints ### UPS Manager - I2C battery monitoring (MAX17040-compatible) - Battery percentage, voltage, current tracking - Power source detection (AC/Battery) - Safe shutdown triggers at configurable thresholds - Event callbacks for battery warnings - SSE and BLE notification integration - 3 UPS API endpoints ### BLE Manager - Bluetooth Low Energy notification support - Auto-detects BLE capability - Multiple notification types (updates, battery, shutdown, etc.) - BLE advertising management - Device connection tracking - 4 BLE API endpoints ### Plugin Framework - Dynamic plugin loading/unloading - Plugin lifecycle management (load, enable, disable, unload) - Hook system for extensibility - JSON-based metadata - Example "Hello World" plugin included - 7 Plugin API endpoints ### Frontend (Remix.js + React) - Cyberpunk-themed responsive UI - Dashboard with system status - PM3 command interface with history - Settings page with WiFi and Update management - Command logs viewer - Theme toggle (Dark/Light/Auto) - Server-side rendering (SSR) - Mobile-first responsive design ### System Integration - Systemd service with security hardening - Automated install/uninstall scripts - Environment configuration template - Hardware access groups (i2c, bluetooth, gpio, dialout) - Pi-gen stage 04 integration for OS image building - Port conflict resolution with ttyd-bash - I2C interface auto-enable for UPS HAT ### Testing - test_backend.py - Backend API tests - test_ups.py - UPS manager tests - test_ble.py - BLE manager tests - test_plugins.py - Plugin manager tests - All tests passing locally ### Documentation - 12 comprehensive documentation files - claude.md - AI development guide - WIFI_MANAGER.md - WiFi management guide - UPDATE_MANAGER.md - Update system guide - PORT_CONFLICT.md - Port conflict resolution guide - MVP_COMPLETE.md - MVP implementation summary - PROJECT_STATUS.md - Project status and roadmap - systemd/README.md - Service management docs - pi-gen integration documentation ## Technical Details - ~5,000+ lines of backend code - 11 Python dependencies (smbus2 added for UPS) - FastAPI with async/await throughout - Type hints and docstrings on all functions - RESTful API design with SSE for notifications - Security hardening (non-root, protected dirs, resource limits) ## Next Steps - Deploy to Raspberry Pi Zero 2 W hardware - Test with real Proxmark3 device - Test UPS HAT integration - Test BLE on Pi hardware - Build custom OS image with pi-gen - Performance optimization for Pi Zero 2 W 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Dangerous Pi - pi-gen Stage Integration
This directory contains the pi-gen stage scripts for installing Dangerous Pi into the custom Raspberry Pi OS image.
Files
00-run.sh- Pre-chroot script that prepares application files00-run-chroot.sh- Chroot script that installs Dangerous Pi and dependencies
What Gets Installed
The stage performs the following actions:
1. Python Dependencies
Installs all required Python packages via pip:
- FastAPI and Uvicorn (web framework and ASGI server)
- AsyncIO libraries (aiosqlite, aiohttp)
- Pydantic (data validation)
- SSE-Starlette (Server-Sent Events)
- psutil (system monitoring)
- smbus2 (I2C communication for UPS)
2. Application Installation
- Creates
/opt/dangerous-pidirectory - Copies application files (backend, frontend, plugins)
- Creates data and logs directories
- Sets proper ownership (pi:pi)
3. Configuration
- Creates environment file from template at
/opt/dangerous-pi/.env - Configures default settings (can be customized post-install)
4. Systemd Service
- Installs systemd service unit
- Enables service to start on boot
- Configures service with security hardening
5. Hardware Access
- Enables I2C interface in
/boot/config.txt(for UPS HAT) - Adds
piuser to hardware groups:i2c- I2C bus accessbluetooth- Bluetooth accessgpio- GPIO pin accessdialout- Serial device access (for Proxmark3)
Build Process
During the pi-gen build:
-
00-run.shexecutes outside the chroot:- Copies application files to temporary location
- Prepares directory structure
-
00-run-chroot.shexecutes inside the chroot:- Installs Python dependencies
- Copies files to
/opt/dangerous-pi - Configures system
- Installs and enables systemd service
Integration with Existing pi-pm3 Stages
Dangerous Pi (stage 04) runs after:
- Stage 01: Proxmark3 installation
- Stage 02: RaspAP installation
- Stage 03: ttyd installation
This order ensures all dependencies are available.
Port Conflict Handling
The ttyd-bash service (from stage 03) uses port 8000, which conflicts with Dangerous Pi's default port. See the port conflict handling task for resolution options.
Post-Build Configuration
After the image is built and booted, you can customize:
- Edit
/opt/dangerous-pi/.envto configure settings - Restart service:
sudo systemctl restart dangerous-pi - View status:
sudo systemctl status dangerous-pi - View logs:
sudo journalctl -u dangerous-pi -f
Testing the Stage
To test this stage during development:
- Make changes to Dangerous Pi code
- Run pi-gen build (this stage will copy the latest code)
- Flash image to SD card
- Boot Raspberry Pi
- Check service status
Customization
Change Installation Directory
Edit 00-run-chroot.sh:
mkdir -p /your/custom/path
cd /your/custom/path
Also update the systemd service file paths.
Add Additional Dependencies
Edit 00-run-chroot.sh and add to the pip install command:
pip3 install --break-system-packages \
<existing packages> \
your-new-package==1.0.0
Skip Service Auto-Start
Comment out or remove from 00-run-chroot.sh:
# systemctl enable dangerous-pi.service
Troubleshooting
Build Fails - Python Package Error
Check that all package versions in the pip install command match requirements.txt.
Build Fails - Permission Error
Ensure scripts are executable:
chmod +x 00-run.sh 00-run-chroot.sh
Service Doesn't Start After Boot
Check systemd logs:
sudo journalctl -u dangerous-pi -b
Common issues:
- Missing dependencies
- Incorrect file permissions
- Port conflict with ttyd
- Missing environment variables
I2C Not Working
Verify I2C is enabled:
grep i2c_arm /boot/config.txt
ls -l /dev/i2c*
Can't Access Proxmark3
Verify user is in dialout group:
groups pi | grep dialout
ls -l /dev/ttyACM*
Development Workflow
- Make changes to Dangerous Pi code in main repository
- Test locally with
python3 -m app.backend.main - When ready to test in image:
- Run pi-gen build (or incremental build for this stage)
- Flash to SD card and test
- Iterate as needed
Version Management
The VERSION file is copied from the repository root. If it doesn't exist, version defaults to "0.1.0".
To set a specific version:
echo "1.0.0" > /path/to/dangerous-pi/VERSION
Then rebuild the image.