Files
aes67-ESP32-P4/components/aes67_web/include/aes67_web.h
T
bsncubed c2621f192a Step 2.2: config registry and NVS store, GET/POST /api/config
- aes67_web/cfg.c: cfg_register(group, defaults, validate, apply),
  cfg_override_defaults() for project defaults, cfg_get(). Stored values
  are loaded on register and merged over defaults (known keys, matching
  types). NVS keeps only keys that differ from defaults, one JSON string
  per group, so new firmware defaults still reach untouched settings.
- POST /api/config: type check against defaults, per-group validation,
  nothing stored unless every group passes; 400 "group.key: reason".
  Unknown keys/groups are ignored. Returns the new config.
- Core groups registered by their components with the UI's ranges:
  ptp (aes67_ptp), aes67 (aes67_tx, incl. multicast range and mono_sum
  => 1 channel), net/inet (aes67_net), log (aes67_syslog).
- Project: PROJECT.def overrides (hostname p4-aes67, name P4 AES67) and
  the "source" group in main/project_cfg.c.
- Config is stored only; nothing is applied live yet.
- Verified on board: defaults, valid save, 8 rejected values (nothing
  stored), persistence across reboot, restore to defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 23:00:55 +10:00

21 lines
794 B
C

// aes67_web: httpd, embedded index.html, config store (cJSON in NVS), core routes.
// Core component: must not depend on main/ (project code).
#pragma once
#include "cJSON.h"
#include "esp_err.h"
#include "esp_http_server.h"
// Adds fields to the /api/status object. Called on every GET /api/status.
typedef void (*status_cb_t)(cJSON *status);
// Registries: call before or after aes67_web_start(); routes registered early are added on start.
esp_err_t status_register(status_cb_t cb);
esp_err_t web_register_uri(const httpd_uri_t *uri);
// Start httpd on port 80 with the core routes (/, /api/status, /api/config, /api/reboot).
esp_err_t aes67_web_start(void);
// Send a cJSON object as the response body (application/json).
esp_err_t web_send_json(httpd_req_t *req, const cJSON *json);