feat(webconfig): add web configuration portal and MQTT enhancements

Introduce a web configuration portal for easier node management and
provisioning without serial CLI. Enhance MQTT functionality with
improved IATA code validation, dynamic slot management, and
background NTP synchronization. Update web UI elements for better
user experience and security notes regarding open AP usage.
This commit is contained in:
agessaman committed 2026-07-18 09:34:11 -07:00
1 parent 639c07a414
commit a7c1cc631f
12 files changed
+983 -117

No files matched your search

+38 -11
View File
@@ -3,7 +3,16 @@
# Pre-build script: gzip webui/index.html into a PROGMEM C header so the
# webconfig portal can serve the page straight from flash with
# Content-Encoding: gzip. The generated header is .gitignored; this script
# regenerates it whenever the source page (or this script) is newer.
# regenerates it whenever the source page (or this script) content changes.
#
# Freshness is decided by a content hash of the build inputs (not timestamps):
# a generated header written with a skewed/future mtime would otherwise mask a
# later source edit and embed stale UI. gzip output is deterministic (mtime=0),
# so an unchanged source produces an unchanged header.
#
# The generator is idempotent and cheap: when the inputs are unchanged it only
# hashes two small files and returns, so running it from esp32_base on every
# ESP32 build is negligible even for targets that don't compile the portal.
#
# Output: src/helpers/esp32/WebConfigHtml.h
# WEBCONFIG_HTML_GZ[] - gzipped page (PROGMEM)
@@ -21,21 +30,37 @@ SOURCE = os.path.join("webui", "index.html")
OUTPUT = os.path.join("src", "helpers", "esp32", "WebConfigHtml.h")
# __file__ is not defined inside PIO/SCons-executed extra_scripts
SCRIPT = os.path.join("scripts", "generate_webconfig_html.py")
HASH_MARKER = "// build-inputs-sha256: "
def status(msg):
sys.stderr.write("WebConfig HTML: %s\n" % msg)
def needs_rebuild():
if not os.path.isfile(OUTPUT):
return True
out_mtime = os.path.getmtime(OUTPUT)
if os.path.getmtime(SOURCE) > out_mtime:
return True
if os.path.isfile(SCRIPT) and os.path.getmtime(SCRIPT) > out_mtime:
return True
return False
def content_hash():
# Hash the source page and this generator so any change to either forces a
# regenerate, independent of file timestamps.
h = hashlib.sha256()
with open(SOURCE, "rb") as f:
h.update(f.read())
if os.path.isfile(SCRIPT):
h.update(b"\0")
with open(SCRIPT, "rb") as f:
h.update(f.read())
return h.hexdigest()
def stored_hash():
try:
with open(OUTPUT, "r") as f:
for line in f:
if line.startswith(HASH_MARKER):
return line[len(HASH_MARKER):].strip()
if line.startswith("#"): # reached the C preprocessor lines
break
except OSError:
return None
return None
def main():
@@ -43,7 +68,8 @@ def main():
status("ERROR: %s not found" % SOURCE)
sys.exit(2)
if not needs_rebuild():
src_hash = content_hash()
if os.path.isfile(OUTPUT) and stored_hash() == src_hash:
return
with open(SOURCE, "rb") as f:
@@ -56,6 +82,7 @@ def main():
lines = []
lines.append("// Auto-generated by scripts/generate_webconfig_html.py from %s" % SOURCE.replace(os.sep, "/"))
lines.append("// DO NOT EDIT - edit webui/index.html instead.")
lines.append("%s%s" % (HASH_MARKER, src_hash))
lines.append("#pragma once")
lines.append("#include <stdint.h>")
lines.append("#include <pgmspace.h>")