Files
Hodor/.vscode
Aida_Lashkari 194671d387 Add BOOT-button entry to the setup portal and gate the Wi-Fi card behind login
Hold BOOT (GPIO0) for 10s while running to reboot into the captive
portal without needing the current media login (physical access is the
proof). This also covers the "forgotten login" case.

button.c (new)
- button_task polls GPIO0 (pull-up, 50 ms), ignores a press held since
  boot so download-mode entry is unaffected, and calls
  wifi_request_portal_physical() after 10s.
- Started from app_main() right after wifi_start_provisioning_if_needed(),
  only when not provisioning, so it also works while the station is
  retrying an unreachable network.

wifi.c
- wifi_request_portal_physical(): stores a one-shot "portal requested by
  button" flag in NVS (namespace "portal") and restarts. NVS is used
  instead of RTC_DATA_ATTR because the flag was lost across the reset
  on this board.
- wifi_start_provisioning_if_needed(): reads and erases the flag at boot
  (portal_flag_take) and sets s_physical for that portal session only.
  Logs the reset reason.
- Portal without the button (30 failed reconnects, wifi_request_portal())
  stays non-physical and asks for the current login.
- /save (Wi-Fi card) now requires cam_auth_verify() unless s_physical.
- /auth uses cam_auth_set() when s_physical, else cam_auth_change().
- Shared lockout: 5 wrong logins block /save and /auth until restart
  (not applied when s_physical). Failed attempts are delayed by 1 s.
- Physical portal times out after 180 s (normal portal: 300 s).
- Root page gets "var PHYS=0/1" injected before its script via chunked
  send; with PHYS=1 the "current login" fields are hidden and a banner
  is shown.
- html: added current-login fields (wu/wp) to the Wi-Fi form, wrapped
  current-login fields in .cur, /save errors are shown to the user.
- read_body()/send_text() moved above the handlers.

cam_auth.c
- New cam_auth_set(): validates and stores a new login with no check of
  the current one. cam_auth_change() now = cam_auth_verify() +
  cam_auth_set().

Requirements
- cam_auth_load() must run before wifi_start_provisioning_if_needed(),
  otherwise cam_auth_verify() treats auth as disabled and accepts any
  login.
- cam_auth.h: declare cam_auth_set(); declare
  wifi_request_portal_physical() where button.c can see it.

Tested on board: long press reboots into the AP "ESP32_Setup" instead of
reconnecting to the stored network. Not yet tested: Wi-Fi card login
gating, lockout, 180 s timeout, portal page rendering on a phone.
2026-10-11 15:26:53 +03:30
..