Skip to main content

Crate idun_rs

Crate idun_rs 

Source
Expand description

§idun-rs

Async Rust library and terminal UI for streaming EEG, IMU, and impedance data from IDUN Guardian earbuds over Bluetooth Low Energy.

§Supported hardware

ModelBLE nameEEGImpedanceIMUNotes
Guardian Earbud 2.1aIGEBOriginal model
Guardian Earbud 3.0aIGE-XXXXXXNewer hardware

§IDUN Cloud API token (optional)

The Guardian’s BLE wire format is proprietary. For authoritative EEG decoding you can use the IDUN Cloud WebSocket API as a fallback:

  1. Get an API token from https://idun.tech/
  2. Export it: export IDUN_API_TOKEN="your_token"
  3. Pass --cloud to the CLI or use cloud::CloudDecoder in code

Local experimental decoding (--decode / local-decode feature) works without any API token but may not be fully accurate.

§Quick start

use idun_rs::prelude::*;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = GuardianClient::new(GuardianClientConfig::default());
    let (mut rx, handle) = client.connect().await?;
    handle.start_recording().await?;

    while let Some(event) = rx.recv().await {
        match event {
            GuardianEvent::Eeg(r) => println!("EEG idx={} ts={:.0}ms", r.index, r.timestamp),
            GuardianEvent::Disconnected => break,
            _ => {}
        }
    }
    Ok(())
}

§Module overview

ModulePurpose
preludeOne-line glob import of the most commonly needed types
guardian_clientBLE scanning, connecting, and the GuardianHandle command API
typesAll event and data types (GuardianEvent, EegReading, etc.)
protocolGATT UUIDs, commands, config bytes, sampling constants
parseBinary decoders for EEG, IMU, and impedance packets
cloudIDUN Cloud WebSocket client for server-side EEG decoding (requires IDUN_API_TOKEN)

Modules§

cloud
IDUN Cloud WebSocket client for server-side EEG decoding.
guardian_client
BLE client for IDUN Guardian EEG earbuds.
parse
Binary decoders for Guardian BLE notification payloads.
prelude
Convenience re-exports for downstream crates.
protocol
GATT UUIDs, sampling constants, and BLE wire-format helpers for IDUN Guardian earbuds.
types
Data types for events emitted by the IDUN Guardian BLE client.