aranet-service
Background collector and HTTP REST API for Aranet sensors.
A service daemon that continuously monitors Aranet devices and exposes sensor data via a REST API. Built with Axum for high-performance async HTTP handling.
Features
- Background collection - Automatically poll configured devices at regular intervals
- REST API - Query current readings, history, and device information via HTTP
- WebSocket support - Real-time streaming of sensor updates
- Local persistence - Store readings in SQLite via aranet-store
- Configurable - TOML-based configuration for devices, intervals, and server settings
- Health endpoint - Monitor service status for integration with monitoring systems
Installation
Or build from source:
Usage
# Start the service with default configuration
# Specify a custom config file
# Specify bind address and port
Configuration
Create a configuration file at ~/.config/aranet/service.toml:
[]
= "127.0.0.1:3000"
[]
= "~/.local/share/aranet/data.db"
[[]]
= "AA:BB:CC:DD:EE:FF"
= "Living Room"
= 60 # seconds
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Service health check |
| GET | /api/devices |
List all configured devices |
| GET | /api/devices/:id |
Get device details |
| GET | /api/devices/:id/current |
Get current reading |
| GET | /api/devices/:id/readings |
Query stored readings |
| GET | /api/devices/:id/history |
Query device history |
| GET | /api/readings |
Query all readings across devices |
| WS | /api/ws |
WebSocket for real-time updates |
Query Parameters
For /readings and /history endpoints:
| Parameter | Type | Description |
|---|---|---|
since |
Unix timestamp | Filter records after this time |
until |
Unix timestamp | Filter records before this time |
limit |
Integer | Maximum number of records |
offset |
Integer | Skip this many records (pagination) |
Example Requests
# Check service health
# List devices
# Get current reading
# Query history with time range
Related Crates
This crate is part of the aranet workspace:
| Crate | crates.io | Description |
|---|---|---|
| aranet-core | Core BLE library for device communication | |
| aranet-types | Shared types for sensor data | |
| aranet-store | Local data persistence | |
| aranet-cli | Command-line interface | |
| aranet-tui | Terminal UI dashboard | |
| aranet-gui | - | Desktop GUI application |
| aranet-wasm | - | WebAssembly module |
License
MIT
Made with ❤️ by Cameron Rye