Files
espresso_frame/firmware/main/wifi_provisioning.h
T
tfaour de449d5973 Finish captive portal: NVS config, POST handler, STA connect, AP identity
Splits provisioning (softAP + captive portal + NVS-backed config) into
wifi_provisioning.c and home-network connection into frame_client.c.
/save_config now parses the form body and persists it to NVS; on boot the
device goes straight to STA mode if a config exists, retrying a few times
before falling back to provisioning if the home network is unreachable.

The provisioning AP is now always named ESPRESSO with a random per-device
password (generated once, persisted in NVS) instead of a fixed Kconfig
value, drawn from a charset that avoids visually ambiguous characters since
it'll be read off the e-ink panel and possibly typed by hand.
2026-07-18 10:48:52 -04:00

40 lines
1.2 KiB
C

#pragma once
#include <stddef.h>
#include "esp_err.h"
#define FRAME_CFG_SSID_MAX_LEN 32
#define FRAME_CFG_PASSWORD_MAX_LEN 64
#define FRAME_CFG_SERVER_MAX_LEN 128
#define FRAME_AP_PASSWORD_LEN 10
typedef struct {
char sta_ssid[FRAME_CFG_SSID_MAX_LEN + 1];
char sta_password[FRAME_CFG_PASSWORD_MAX_LEN + 1];
char toolsserver[FRAME_CFG_SERVER_MAX_LEN + 1];
} frame_config_t;
/**
* Loads the saved home-network config from NVS.
* Returns ESP_ERR_NVS_NOT_FOUND if the device has never been provisioned.
*/
esp_err_t frame_config_load(frame_config_t *out);
/** Saves the home-network config to NVS. */
esp_err_t frame_config_save(const frame_config_t *cfg);
/**
* Returns this device's provisioning AP identity: a fixed SSID (from
* Kconfig) and a password that's generated once on first use and persisted
* in NVS from then on. The password is drawn from an easy-to-type charset
* since it's shown on the e-ink panel (as both a QR code and plaintext) and
* may need to be typed in by hand.
*/
void ap_identity_get(char *ssid_out, size_t ssid_len, char *pass_out, size_t pass_len);
/**
* Brings up the ESPRESSO softAP + captive portal (DNS + HTTP) so the user
* can provision the device. Does not return.
*/
void wifi_provisioning_start(void);