3.5 KiB · text History 9174a13
// The acme-camera talk's types (content/presentations/acme-camera.md),
// kept here so the compiler checks what the slides show. Nothing builds
// them on purpose.
#![allow(dead_code)]

use std::collections::HashSet;

fn main() {
    println!("Hello, world!");
}

enum MotionDetectionMode {
    OnlyPIR,
    PIRWakesRadar,
    OnlyRadar,
    Off
}

enum LightControlMode {
    DuskDawn,
    Motion{cooldown: u32},
    Off
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum Weekday {
    M,
    T,
    W,
    R,
    F,
    S,
    U
}

struct TimerConfig {
    start_time: u64,
    end_time: u64,
    schedule_days: HashSet<Weekday>
}

enum PowerCtlMode {
    Detection{cooldown: u32},
    Timer{configs: Vec<TimerConfig>},
}

enum PowerSource {
    Battery,
    External,
}

struct PowerReading {
    source: PowerSource,
    timestamp: u64,
    voltage_mv: u32,
    current_ma: i32,              // + charge / - drain
    state_of_charge: Option<u8>,  // fuel gauge, %
    time_to_empty_s: Option<u32>, // rundown estimate
}
// portalctl

enum SetupTransport {
    Ble,                                  // phone app, through mcuctl and the MCU radio
    SoftAp { ssid: String, psk: String }, // fallback without the app
}

enum PortalMode {
    Setup { via: SetupTransport }, // first boot / factory reset
    Status,                        // on the home network after provisioning
    Off,                           // portal disabled once cloud-managed
}

enum WifiSecurity {
    Open,
    Wpa2Psk,
    Wpa3Sae,
}

struct WifiCredentials {
    ssid: String,
    security: WifiSecurity,
    passphrase: Option<String>,
}

struct CloudClaim {
    claim_token: String, // from QR / app, exchanged for device certs
    display_name: String,
}

enum ProvisioningState {
    AwaitingCredentials,
    JoiningNetwork,
    Claiming,
    Provisioned,
    Failed { reason: String },
}

// what portalctl publishes for configctl to apply
enum ConfigRequest {
    Network(WifiCredentials),
    Cloud(CloudClaim),
    DisplayName(String),
}

enum BootSlot {
    A,
    B,
}

// read-only view for the status portal
struct DeviceStatus {
    display_name: String,
    firmware_slot: BootSlot,          // ties to the A+B boot plan
    state_of_charge: Option<u8>,      // from powerctl
    motion_mode: MotionDetectionMode, // from mcuctl
    cloud_connected: bool,
}

// cameractl

enum CaptureTrigger {
    Motion,
    LiveView,
    Timer,
}

enum Resolution {
    P720,
    P1080,
    P1440,
}

struct ClipPolicy {
    resolution: Resolution,
    max_len_s: u16,
    extend_on_motion: bool, // keep recording while the radar still sees someone
}

enum Sink {
    ClipBuffer,
    Cloud,
    Inference,
}

struct Clip {
    id: u64,
    trigger: CaptureTrigger,
    started_at: u64,
    len_ms: u32,
    uploaded: bool,
}

// configctl

struct DeviceConfig {
    version: u32,
    display_name: String,
    network: WifiCredentials,
    cloud: CloudConfig,
    motion: MotionDetectionMode,
    light: LightControlMode,
    power: PowerCtlMode,
    processing: ProcessingConfig,
}

struct CloudConfig {
    endpoint: String,
    device_id: String,
}

enum ProcessingConfig {
    Off,
    Detect { targets: Vec<InferenceTarget>, threshold: f32 },
}

enum ConfigResult {
    Applied { version: u32 },
    Rejected { reason: String },
}

// infctl

struct Model {
    name: String,
    version: String,
    input: (u16, u16),
}

enum InferenceTarget {
    Person,
    Vehicle,
    Package,
    Animal,
}

struct Detection {
    target: InferenceTarget,
    confidence: f32,
    bbox: (u16, u16, u16, u16),
}