aranet-store 0.1.8

Local data persistence for Aranet sensor readings
Documentation

aranet-store

Local data persistence for Aranet sensor readings using SQLite.

This crate provides SQLite-based storage for Aranet sensor data, enabling offline access, history caching, and efficient queries without requiring a device connection.

Features

  • SQLite-based storage — Single-file database, no server needed
  • Incremental history sync — Only download new records from device
  • Query by device, time range — With pagination support
  • Sync state tracking — Per-device progress for efficient updates
  • Deduplication — Automatic deduplication of history records

Installation

[dependencies]
aranet-store = "0.1"

Usage

use aranet_store::{Store, ReadingQuery, HistoryQuery};

// Open or create database at default location
let store = Store::open_default()?;

// Register a device
store.upsert_device("AA:BB:CC:DD:EE:FF", Some("Living Room"))?;

// Store a reading
store.insert_reading("AA:BB:CC:DD:EE:FF", &reading)?;

// Query readings with filters
let query = ReadingQuery::new()
    .device("AA:BB:CC:DD:EE:FF")
    .limit(100);
let readings = store.query_readings(&query)?;

// Query cached history
let query = HistoryQuery::new()
    .device("AA:BB:CC:DD:EE:FF")
    .since(one_hour_ago);
let history = store.query_history(&query)?;

// Get sync state for incremental updates
let sync_state = store.get_sync_state("AA:BB:CC:DD:EE:FF")?;

Database Location

By default, the database is stored at platform-specific locations:

Platform Path
Linux ~/.local/share/aranet/data.db
macOS ~/Library/Application Support/aranet/data.db
Windows C:\Users\<user>\AppData\Local\aranet\data.db

Schema

The database contains four tables:

Table Description
devices Known devices and their metadata (name, firmware, model)
readings Current readings captured over time
history Historical records downloaded from device memory
sync_state Tracks incremental sync progress per device

CLI Integration

The aranet-cli tool provides commands for interacting with the store:

# Sync device history to local database
aranet sync --device <ADDRESS>

# Query cached data
aranet cache devices   # List cached devices
aranet cache stats     # Show cache statistics
aranet cache history   # Query cached history
aranet cache info      # Show database info

Related Crates

This crate is part of the aranet workspace:

Crate crates.io Description
aranet-core crates.io Core BLE library for device communication
aranet-types crates.io Shared types for sensor data
aranet-cli crates.io Command-line interface
aranet-tui crates.io Terminal UI dashboard
aranet-service - Background collector and REST API
aranet-gui - Desktop application (planned)
aranet-wasm - WebAssembly module (planned)

License

MIT


Made with ❤️ by Cameron Rye