Add Typed Display Settings Administration
Implements admin-only Display settings with generation-checked Apply, Save, Load, Defaults, and Reset operations across the web UI, CLI, SSH dispatcher, and local UI owner. Adds bounded HTTP handling, session-isolated operation results, browser lifecycle support, and comprehensive host tests and documentation.
This commit is contained in:
@@ -59,6 +59,24 @@ admin = "--admin" in sys.argv
|
||||
settings = "--settings" in sys.argv
|
||||
serial_settings = "--serial-settings" in sys.argv
|
||||
accounts = "--accounts" in sys.argv
|
||||
display = "--display" in sys.argv
|
||||
if display:
|
||||
HEADERS["nvs_flash.h"] = '#pragma once\n#include "esp_err.h"\nesp_err_t nvs_flash_init(void);\n'
|
||||
HEADERS["nvs.h"] = '''#pragma once
|
||||
#include <stddef.h>
|
||||
#include "esp_err.h"
|
||||
typedef int nvs_handle_t;
|
||||
#define NVS_READONLY 0
|
||||
#define NVS_READWRITE 1
|
||||
#define ESP_ERR_NVS_NOT_FOUND 0x1102
|
||||
#define ESP_ERR_NVS_TYPE_MISMATCH 0x1103
|
||||
#define ESP_ERR_NVS_INVALID_LENGTH 0x110c
|
||||
esp_err_t nvs_open(const char *, int, nvs_handle_t *);
|
||||
esp_err_t nvs_get_blob(nvs_handle_t, const char *, void *, size_t *);
|
||||
esp_err_t nvs_set_blob(nvs_handle_t, const char *, const void *, size_t);
|
||||
esp_err_t nvs_commit(nvs_handle_t);
|
||||
void nvs_close(nvs_handle_t);
|
||||
'''
|
||||
network = "--network" in sys.argv
|
||||
if network:
|
||||
HEADERS["esp_wifi_types.h"] = "#pragma once\ntypedef int wifi_auth_mode_t;\n"
|
||||
@@ -186,6 +204,13 @@ with tempfile.TemporaryDirectory(prefix="web-cookie-auth-") as directory:
|
||||
settings_source += ' serial_service_counters_t serial_counters = {0};\n' + acquisition
|
||||
settings_source += ' return snprintf(response, capacity,\n' + serial_format + ',\n' + serial_arguments + ');\n}\n'
|
||||
(tmp / 'settings_production.h').write_text(settings_source)
|
||||
if display:
|
||||
ui_source = (ROOT / 'src/local_status_ui.c').read_text()
|
||||
names = ('local_status_ui_get_config', 'local_status_ui_get_settings', 'local_status_ui_update_settings', 'local_status_ui_apply_config', 'local_status_ui_hold_for_diagnostics')
|
||||
(tmp / 'display_owner_production.h').write_text('\n'.join(function(ui_source, name) for name in names))
|
||||
console_source = (ROOT / 'src/local_ui_console.c').read_text()
|
||||
names = ('print_usage', 'print_config', 'parse_timeout', 'apply_parameter', 'command_display')
|
||||
(tmp / 'display_console_production.h').write_text('\n'.join(function(console_source, name) for name in names))
|
||||
if network:
|
||||
wifi_source = (ROOT / 'src/wifi_config.c').read_text()
|
||||
mdns_source = (ROOT / 'src/mdns_config.c').read_text()
|
||||
@@ -221,6 +246,7 @@ with tempfile.TemporaryDirectory(prefix="web-cookie-auth-") as directory:
|
||||
*(["-DHOST_SERIAL_SETTINGS"] if serial_settings else []),
|
||||
*(["-DHOST_ACCOUNTS"] if accounts else []),
|
||||
*(["-DHOST_NETWORK"] if network else []),
|
||||
*(["-DHOST_DISPLAY"] if display else []),
|
||||
"-I" + str(tmp), "-I" + str(ROOT / "src"), *map(str, sources), "-lcrypto",
|
||||
"-o", str(tmp / "test")], check=True, timeout=30)
|
||||
subprocess.run([str(tmp / "test")], check=True, timeout=20)
|
||||
|
||||
Reference in New Issue
Block a user