FastAPI cloud service for testing rpi-hub-service WebSocket communication.
- WebSocket hub connection endpoint (
/hub) - JWT authentication for API endpoints
- Device token authentication for hub connections
- In-memory storage for testing
- REST API for triggering commands and viewing telemetry
- Full bidirectional messaging with hub service
cd cloud-services
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtcp .env.example .env
# Edit .env with your settingsuvicorn src.main:app --host 0.0.0.0 --port 8080 --reloadServer will be available at http://localhost:8080
API documentation at http://localhost:8080/docs
POST /auth/login- Login with username/password, get JWT tokenGET /auth/me- Get current user info
GET /api/hubs- List connected hubsGET /api/hubs/{hubId}- Get hub detailsGET /api/hubs/{hubId}/telemetry- Get telemetry dataPOST /api/hubs/{hubId}/commands/write- Send serial write commandPOST /api/hubs/{hubId}/commands/flash- Send flash firmware commandPOST /api/hubs/{hubId}/commands/restart- Send restart device command
WS /hub- Hub connection endpoint (device token auth)
-
Start this cloud service:
uvicorn src.main:app --host 0.0.0.0 --port 8080 --reload
-
Configure rpi-hub-service
.env:SERVER_ENDPOINT=ws://localhost:8080/hub DEVICE_TOKEN=dev-token-rpi-bridge-01
-
Start rpi-hub-service:
cd ../rpi-hub-service uvicorn src.main:app --host 0.0.0.0 --port 8080 --reload
- Username:
admin, Password:<your password> - Username:
developer, Password:<your password>