Crate aingle_minimal

Crate aingle_minimal 

Source
Expand description

AIngle

The Semantic Infrastructure for Intelligent Applications

Enabling enterprises to build secure, scalable, and intelligent distributed systems

Build Status License Rust

FeaturesQuick StartPlatformsESP32 SetupWebsite


§AIngle Minimal

Ultra-lightweight AIngle node for IoT devices with < 1MB RAM footprint. Supports ESP32, Raspberry Pi, and desktop platforms.

§Features

FeatureDescriptionUse Case
coapCoAP protocol (default)IoT communication
restREST API serverSDK integration
sqliteSQLite storageEdge devices
rocksdbRocksDB storageHigh-performance
bleBluetooth LE (Desktop)macOS/Linux/Windows
ble-esp32Bluetooth LE (ESP32)Embedded IoT
webrtcWebRTC transportBrowser nodes
hw_walletLedger/Trezor supportSecure signing
smart_agentsHOPE AI agentsEdge intelligence

§Quick Start

# Cargo.toml
[dependencies]
aingle_minimal = "0.3"
use aingle_minimal::{MinimalNode, Config};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::iot_mode();
    let mut node = MinimalNode::new(config)?;
    smol::block_on(node.run())?;
    Ok(())
}

§REST API & SDKs

Enable the rest feature to expose an HTTP API for SDK integration:

# Run with REST API on port 8080
aingle-minimal run --rest-port 8080

§Endpoints

MethodPathDescription
GET/api/v1/infoNode information
POST/api/v1/entriesCreate entry
GET/api/v1/entries/:hashGet entry
GET/api/v1/peersList peers
GET/api/v1/statsStatistics

§Official SDKs

LanguagePackage
JavaScript@apilium/aingle-sdk
Pythonaingle-sdk
Goaingle-sdk-go
SwiftAIngleSDK
Kotlinaingle-sdk

§Platform Support

PlatformTargetBLE Feature
macOSaarch64-apple-darwinble
Linuxx86_64-unknown-linux-gnuble
Windowsx86_64-pc-windows-msvcble
ESP32xtensa-esp32-espidfble-esp32
ESP32-C3riscv32imc-esp-espidfble-esp32
ESP32-S3xtensa-esp32s3-espidfble-esp32

§ESP32 Setup

To compile for ESP32 with Bluetooth LE:

§1. Install ESP Toolchain

# Install espup (ESP Rust toolchain installer)
cargo install espup
espup install

# Source the environment (add to .bashrc/.zshrc)
. $HOME/export-esp.sh

§2. Create sdkconfig.defaults

# Required for BLE
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_ENABLED=y
CONFIG_BT_BLUEDROID_ENABLED=n
CONFIG_BT_NIMBLE_ENABLED=y

# Optional: Persist bonding info
CONFIG_BT_NIMBLE_NVS_PERSIST=y

§3. Build

# For ESP32
cargo build --target xtensa-esp32-espidf --features ble-esp32

# For ESP32-C3 (RISC-V)
cargo build --target riscv32imc-esp-espidf --features ble-esp32

# For ESP32-S3
cargo build --target xtensa-esp32s3-espidf --features ble-esp32

§4. Flash

espflash flash target/xtensa-esp32-espidf/release/your-app

§Memory Budget

ComponentBudget
Runtime128KB
Crypto64KB
Network128KB
Storage128KB
App64KB
Total512KB

§License

Apache 2.0 - See LICENSE

§AIngle Minimal - Ultra-Lightweight IoT Node

Minimal AIngle node implementation optimized for resource-constrained IoT devices.

§Overview

This crate provides a complete AIngle node that runs on devices with less than 1MB RAM, making it suitable for ESP32, Arduino, Raspberry Pi Pico, and similar embedded systems.

§Features

  • Ultra-light footprint: Target <512KB RAM, <5MB storage
  • Sub-second confirmation: Configurable publish intervals (default 5s)
  • Zero-fee transactions: No staking or gas fees required
  • Mesh networking: WiFi Direct, BLE, LoRa, Zigbee support
  • Battery-aware: Adaptive power modes (deep sleep, light sleep, active)
  • CoAP Protocol: Lightweight alternative to HTTP for IoT
  • DTLS Security: Encrypted communications with PSK or certificates
  • OTA Updates: Secure over-the-air firmware updates
  • Smart Agents: Optional AI capabilities for edge intelligence

§Quick Start

use aingle_minimal::{MinimalNode, Config};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create node with IoT-optimized config
    let config = Config::iot_mode();
    let mut node = MinimalNode::new(config)?;

    // Run the node
    smol::block_on(node.run())?;
    Ok(())
}

§Advanced Examples

§Sensor Integration

use aingle_minimal::{MinimalNode, SensorManager, SensorType, Config};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut node = MinimalNode::new(Config::iot_mode())?;
    let mut sensors = SensorManager::new();

    // Add temperature sensor
    sensors.add_sensor(SensorType::Temperature, 0x48)?;

    // Read and publish sensor data
    let reading = sensors.read(SensorType::Temperature)?;
    node.publish_sensor_data(reading)?;
    Ok(())
}

§CoAP Server

use aingle_minimal::{CoapServer, CoapConfig};

async fn run() -> Result<(), Box<dyn std::error::Error>> {
    let config = CoapConfig::default();
    let server = CoapServer::new(config).await?;

    // Register resource handlers
    server.register_resource("/temperature", |req| {
        // Handle GET /temperature
        Ok("23.5".into())
    });

    server.run().await?;
    Ok(())
}

§Power Management

use aingle_minimal::{PowerManager, PowerProfile, BatteryInfo};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut power = PowerManager::new();

    // Check battery and adjust power mode
    let battery = power.battery_info()?;
    if battery.percentage < 20.0 {
        power.set_profile(PowerProfile::PowerSave)?;
    }

    // Sleep when idle
    power.sleep(std::time::Duration::from_secs(10))?;
    Ok(())
}

§Smart Agent (Edge AI)

use aingle_minimal::{SmartNode, SmartNodeConfig, SensorAdapter};

let config = SmartNodeConfig::default();
let mut smart_node = SmartNode::new(config)?;

// Agent learns from sensor patterns
let adapter = SensorAdapter::new();
smart_node.attach_sensor(adapter);

// Run agent loop
loop {
    smart_node.step()?;
    smol::Timer::after(std::time::Duration::from_secs(1)).await;
}

§Memory Budget

ComponentBudget
Runtime128KB
Crypto64KB
Network128KB
Storage128KB
App64KB
Total512KB

§Feature Flags

FeatureDescriptionDependencies
coapCoAP server and client (default)coap-lite
sqliteSQLite storage backendrusqlite
rocksdbRocksDB storage backend (faster)rocksdb
webrtcWebRTC transport for browserswebrtc, bytes
bleBluetooth LE for Desktop (macOS/Linux/Windows)btleplug, uuid
ble-esp32Bluetooth LE for ESP32 devicesesp32-nimble
hw_walletHardware wallet support (Ledger/Trezor)ledger-transport-hid
ai_memoryTitans memory system for agentstitans_memory
smart_agentsHOPE agents integrationhope_agents
no_stdCompile without standard library-

§Platform Support

PlatformTargetBLE Feature
macOSx86_64-apple-darwin, aarch64-apple-darwinble
Linuxx86_64-unknown-linux-gnuble
Windowsx86_64-pc-windows-msvcble
ESP32xtensa-esp32-espidfble-esp32
ESP32-C3riscv32imc-esp-espidfble-esp32
ESP32-S3xtensa-esp32s3-espidfble-esp32
Raspberry Pi Picothumbv6m-none-eabi-

§ESP32 Setup (ble-esp32 feature)

To compile for ESP32 with Bluetooth LE support:

§1. Install ESP-IDF Toolchain

# Install espup (ESP Rust toolchain installer)
cargo install espup
espup install

# Source the environment
. $HOME/export-esp.sh

§2. Create sdkconfig.defaults

CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_ENABLED=y
CONFIG_BT_BLUEDROID_ENABLED=n
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_BT_NIMBLE_NVS_PERSIST=y

§3. Build for ESP32

cargo build --target xtensa-esp32-espidf --features ble-esp32

Re-exports§

pub use config::StorageBackendType;
pub use storage_factory::DynamicStorage;
pub use storage_trait::StorageBackend;
pub use storage_trait::StorageStats;
pub use coap::CoapConfig;
pub use coap::CoapServer;
pub use config::Config;
pub use config::GossipConfig;
pub use config::MeshMode;
pub use config::PowerMode;
pub use config::StorageConfig;
pub use config::TransportConfig;
pub use discovery::DiscoveredPeer;
pub use discovery::Discovery;
pub use dtls::DtlsConfig;
pub use dtls::DtlsSession;
pub use dtls::SecureCoap;
pub use dtls::SecurityMode;
pub use error::CryptoError;
pub use error::Error;
pub use error::GossipError;
pub use error::NetworkError;
pub use error::Result;
pub use error::StorageError;
pub use error::SyncError;
pub use gossip::BloomFilter;
pub use gossip::GossipManager;
pub use gossip::GossipStats;
pub use gossip::MessagePriority;
pub use gossip::TokenBucket;
pub use graph::GraphStats as SemanticGraphStats;
pub use graph::SemanticGraph;
pub use graph::SemanticQuery;
pub use graph::SemanticTriple;
pub use graph::TripleObject;
pub use node::MinimalNode;
pub use node::PeerRecord;
pub use ota::OtaManager;
pub use ota::UpdateChannel;
pub use ota::UpdateInfo;
pub use ota::UpdateState;
pub use power::BatteryInfo;
pub use power::PowerManager;
pub use power::PowerProfile;
pub use sensors::CalibrationParams;
pub use sensors::Sensor;
pub use sensors::SensorManager;
pub use sensors::SensorReading;
pub use sensors::SensorType;
pub use sync::PeerSyncState;
pub use sync::SyncManager;
pub use sync::SyncResult;
pub use sync::SyncStats;
pub use types::*;

Modules§

coap
CoAP Transport for IoT nodes
config
Configuration for the minimal AIngle node.
crypto
Minimal cryptography for IoT nodes
discovery
Multi-protocol peer discovery for AIngle nodes
dtls
DTLS Security Layer for CoAP
error
Error types for the minimal AIngle node.
gossip
Optimized Gossip Protocol for AIngle Minimal
graph
Semantic Graph integration for AIngle Minimal
network
Minimal networking for IoT nodes
node
The main MinimalNode implementation.
ota
Over-The-Air (OTA) Update Manager for IoT Devices
power
Power Management for IoT Devices
sensors
Sensor Abstraction Layer for IoT Devices
storage
SQLite storage backend for IoT nodes
storage_factory
Storage factory for dynamic backend selection
storage_trait
Storage backend trait definition
sync
Node-to-node synchronization protocol
types
Core data types for the minimal AIngle node.

Constants§

ENV_IOT_MODE
Environment variable for enabling IoT mode.
ENV_PUBLISH_INTERVAL
Environment variable for configuring publish interval.
MEMORY_BUDGET
Target memory budget in bytes (512KB).
MSRV
Minimum supported Rust version.
VERSION
Version information for the crate.