From 7f51c6006295db83abd9f7396f73e9807601e3e0 Mon Sep 17 00:00:00 2001 From: bonamin Date: Fri, 27 Feb 2026 10:17:38 +0200 Subject: [PATCH] fix: Trying to fix Auto Restart. And Fixed MQTT admin auth --- backend/mqtt/auth.py | 6 +++--- frontend/src/manufacturing/ProvisioningWizard.jsx | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/mqtt/auth.py b/backend/mqtt/auth.py index 6701a30..7f9cde4 100644 --- a/backend/mqtt/auth.py +++ b/backend/mqtt/auth.py @@ -18,7 +18,7 @@ User types handled: - Kiosk users (e.g. "PV25L22BP01R01-kiosk"): Same HMAC auth derived from the full kiosk username. ACL: allowed to access topics of their base device (suffix stripped). -- bonamin, NodeRED, and other non-device users: +- admin, bonamin, NodeRED, and other non-device users: These connect via the passwd file backend (go-auth file backend). They never reach this HTTP backend — go-auth resolves them first. The ACL endpoint below handles them defensively anyway (superuser list). @@ -35,7 +35,7 @@ LEGACY_PASSWORD = "vesper" # Users authenticated via passwd file (go-auth file backend). # If they somehow reach the HTTP ACL endpoint, grant full access. -SUPERUSERS = {"bonamin", "NodeRED"} +SUPERUSERS = {"admin", "bonamin", "NodeRED"} def _derive_password(username: str) -> str: @@ -86,7 +86,7 @@ async def mqtt_auth_user( or kiosk variant: "PV25L22BP01R01-kiosk" Password = HMAC-derived (new firmware) or "vesper" (legacy firmware) - Note: bonamin and NodeRED authenticate via the go-auth passwd file backend + Note: admin, bonamin and NodeRED authenticate via the go-auth passwd file backend and never reach this endpoint. """ if _is_valid_password(username, password): diff --git a/frontend/src/manufacturing/ProvisioningWizard.jsx b/frontend/src/manufacturing/ProvisioningWizard.jsx index 2fc365b..0593a0e 100644 --- a/frontend/src/manufacturing/ProvisioningWizard.jsx +++ b/frontend/src/manufacturing/ProvisioningWizard.jsx @@ -534,8 +534,18 @@ function StepFlash({ device, onFlashed }) { setFwProgress(100); appendLog("Flash complete. Resetting device…"); - // 5. Hard-reset via RTS — device boots into user code automatically - await loaderRef.current.after("hard_reset"); + // 5. Manual hard-reset via RTS pulse (ESP32: RTS → EN pin) + // esptool-js HardReset only calls setRTS(false) which is incomplete. + // Full pulse: RTS high (EN=LOW → chip in reset) → wait → RTS low (EN=HIGH → boot) + try { + const transport = loaderRef.current.transport; + await transport.setRTS(true); // pull EN low → enter reset + await new Promise((r) => setTimeout(r, 100)); + await transport.setRTS(false); // release EN → boot into user code + await new Promise((r) => setTimeout(r, 100)); + } catch (rstErr) { + appendLog(`[Reset warning: ${rstErr.message}]`); + } appendLog("Hard reset sent. Device is booting…"); // 6. Disconnect the esptool transport so it releases the port lock