Skip to main content

Crate wifi_caddy

Crate wifi_caddy 

Source
Expand description

§wifi-caddy

Platform-agnostic config storage traits, HTTP config portal, and form generation for WiFi configuration managers.

This crate provides the core abstractions used by wifi-caddy-proc (derive macro) and platform-specific runtime crates like esp-wifi-caddy:

  • Config storage traits (ConfigStorage, ConfigValue, ConfigLoadStore, ConfigGet, ConfigApi, ConfigFormGen) for key-value config persistence.
  • HTTP config portal (feature portal) with DHCP, optional captive-portal DNS, and a config UI server built on edge-http and embassy-net.
  • Helper types (ConfigStorageParams, ConfigUiOptions, ConfigHandle) used by the derive macro and platform init macros.

§Usage

Add wifi-caddy alongside wifi-caddy-proc in your embedded project. A platform crate (e.g. esp-wifi-caddy) provides the storage backend and WiFi initialization.

[dependencies]
wifi-caddy = "0.1"
wifi-caddy-proc = "0.1"
# Platform-specific:
esp-wifi-caddy = "0.1"

§Features

FeatureDefaultDescription
portalyesHTTP config server, DHCP, config UI
captivenoCaptive-portal DNS redirect
debug-servernoAdditional HTTP server on the STA interface
defmtnodefmt logging support
lognolog crate logging support

§Server Tuning

The HTTP server’s buffer sizes, timeouts, and concurrency can be overridden at compile time via environment variables. All are optional and fall back to sensible defaults.

Environment VariableTypeDefaultDescription
WIFI_CADDY_HANDLER_TASKSusize4Concurrent HTTP handler tasks
WIFI_CADDY_TCP_BUF_SIZEusize2048Per-connection TCP receive/send buffer (bytes)
WIFI_CADDY_HTTP_BUF_SIZEusize4096HTTP request/response buffer (bytes)
WIFI_CADDY_KEEPALIVE_TIMEOUT_MSu323000TCP keep-alive timeout (ms)

Set them in the shell:

WIFI_CADDY_HANDLER_TASKS=6 WIFI_CADDY_HTTP_BUF_SIZE=8192 cargo build

Or persistently in .cargo/config.toml (recommended for embedded projects):

[env]
WIFI_CADDY_HANDLER_TASKS = "6"
WIFI_CADDY_TCP_BUF_SIZE = "4096"
WIFI_CADDY_HTTP_BUF_SIZE = "8192"

Modules§

config_storage
Config storage traits and types (load/store, group API, form generation).
portal
Embassy + edge-http portal: AP DHCP, optional DNS, HTTP server loop.

Structs§

ConfigHandle
Handle returned by the platform-specific init macro (e.g. esp_wifi_caddy::wifi_init!). Use .config() to get the shared config mutex to pass into application tasks.