Skip to main content

Crate rusty_esp_arduino

Crate rusty_esp_arduino 

Source
Expand description

rusty_esp_arduino — the sketch a maker types, over the Janus function packages.

use rusty_esp_arduino::prelude::*;

fn setup() {
    board::install(HostBoard::from_env());
    wifi::begin("ssid", "psk");
    cam::begin(cam::Config::qvga_jpeg());
    mic::begin(mic::Config::pcm16_16k());
    stream::listen(80);
}

fn loop_once() {
    if let Some(frame) = cam::grab() {
        stream::push_jpeg(&frame);
    }
    if let Some(pcm) = mic::read() {
        stream::push_pcm(&pcm);
    }
}

fn main() {
    sketch::run(setup, loop_once);
}

Thin by law. Every function here is one call through the board::Board seam into a function package: the camera and microphone are the board’s, the MJPEG server and the RTP/JPEG and PCM senders are rusty_esp_video-esp’s, the WAV reader is rusty_esp_audio-core’s. The facade owns no codec, no socket format and no pixel loop. What it adds is the Arduino shape: free functions, a board installed once, begin before use, Option out, and the reason for a None one call away in last_error.

The same sketch runs on the laptop against host::HostBoard (feature host, on by default) and on a chip against that chip’s board, which is the board half of this package’s plan. Nothing in a sketch names the chip.

Re-exports§

pub use error::Error;
pub use error::last_error;

Modules§

board
The seam: one trait a board implements, installed once per program.
cam
The camera, Arduino-shaped: begin once, grab in the loop.
error
Why the last sketch call returned false or None.
host
The laptop board: the same sketch, no chip.
identity
The device’s own did:mata: minted once from the board’s entropy, kept in the board’s store, the same on every boot — rusty_esp_mid behind the facade’s thin-by-law rule. begin is the one call a sketch makes.
mic
The microphone, Arduino-shaped: begin once, read in the loop.
prelude
What a sketch wants in scope: the modules by name, the two frame types, the runner, and the laptop board.
provision
Provisioning, Arduino-shaped: when the board has no network to join, it advertises the Janus provisioning service over BLE and a phone (or the laptop’s browser, through espino serve’s page) writes the Wi-Fi credentials; the sketch joins with them and stores them in the owner’s settings, so the next boot needs no phone.
radar
The presence sensor, Arduino-shaped: begin once, read in the loop.
sketch
setup once, loop forever — and the bounded form a test needs.
stream
Where frames and blocks go: an MJPEG page any browser opens, RTP/JPEG to a player, raw PCM over UDP to a receiver — all of it rusty_esp_video-esp, all of it the same code on the laptop and on the chip.
wifi
The network, Arduino-shaped: begin or host once, then local_ip.

Constants§

VERSION
Crate version, for logs and capability manifests.