How fufu4826/smartlock-esp32 works
ESP32-035 SmartLock is a locally hosted door-lock firmware: an Owner sets it up in a phone browser, registered phones request timed access, and the Owner manages identities and settings over the device’s AP or home LAN. A physical touchscreen Admin flow provides emergency unlock and factory reset. The graph also includes network recovery, LINE broadcast, and the main persistence/security layers. README documents several capabilities whose implementation was not sampled; those are mapped to their documented source areas, with uncertain wiring omitted.
Main entry points: WebServerManager.cpp HTTP API · IdentityStore.cpp Identity and auth · FirstOwnerSetup.cpp First-owner setup · AccessController.cpp Access control
Components 24
Lock workflows
- First-owner setup
src/app/FirstOwnerSetup.cpp - Access control
src/app/AccessController.cpp - Enrollment management
src/app/EnrollmentManager.cpp - App state machine
src/app/AppStateMachine.cpp - Physical admin
src/app/PhysicalAdmin.cpp - Factory reset
src/app/FactoryResetController.cpp
Web and network
- Phone pages
src/web/WebAssets.h - HTTP API
src/network/WebServerManager.cpp - Wi-Fi and recovery
src/network/NetworkManager.cpp - Canonical origin
src/network/CanonicalOrigin.cpp
Identity and security
- QR sessions
src/qr/SessionManager.cpp - Admin PIN policy
src/security/AdminPin.cpp
Device hardware
- Lock output
src/hardware/LockController.cpp - Display and QR
src/hardware/DisplayManager.cpp - Touch manager
src/hardware/TouchManager.cpp
Storage and services
- Identity and auth
src/storage/IdentityStore.cpp - Device configuration
src/storage/ConfigStore.cpp - SD health and files
src/storage/StorageHealth.cpp - LINE broadcast
src/notifications/LineNotifications.cpp - Time synchronization
src/events/TimeManager.cpp
Other components
- Owner
- Registered phone
- Touch input
- LINE Official Account
Connections 32
- Owner → Phone pages: uses setup/manage
- Registered phone → Phone pages: scans QR
- Phone pages → HTTP API: sends requests
- HTTP API → First-owner setup: dispatches setup
- HTTP API → Access control: dispatches access
- HTTP API → Enrollment management: dispatches management
- HTTP API → Wi-Fi and recovery: reads network state
- HTTP API → LINE broadcast: serves LINE controls
- First-owner setup → QR sessions: validates setup session
- First-owner setup → Identity and auth: creates owner identity
- First-owner setup → Device configuration: saves setup state
- Access control → Identity and auth: checks credentials
- Access control → Device configuration: reads unlock duration
- Access control → Lock output: requests timed unlock
- Enrollment management → QR sessions: validates enrollment
- Enrollment management → Identity and auth: reads and updates identities
- Enrollment management → Canonical origin: builds enrollment URL
- Touch input → Touch manager: provides input
- Touch manager → App state machine: routes touch events
- App state machine → Display and QR: renders state
- Display and QR → QR sessions: renders QR payload
- Touch manager → Physical admin: routes admin touch
- Physical admin → Admin PIN policy: checks PIN
- Physical admin → Lock output: requests emergency unlock
- Physical admin → Factory reset: dispatches reset
- Factory reset → Identity and auth: clears identity data
- Factory reset → Device configuration: clears setup configuration
- Factory reset → SD health and files: resets SD records
- SD health and files → Identity and auth: validates store
- Wi-Fi and recovery → Canonical origin: sets device hostname
- LINE broadcast → LINE Official Account: broadcasts over TLS
- Time synchronization → LINE broadcast: provides time context