How vd-phuc-2k5/smartlock works
SmartLock combines ESP32 firmware, an MQTT/OTP/card backend, and a Next.js card-management client. The main access workflow is RFID scan → server verification → OTP delivery → keypad entry → door actuation; enrollment and camera streaming/capture are additional capabilities. The README documents MQTT and client behavior, while source excerpts show firmware dispatch, backend routes, and integration calls. Several unsampled modules are included as documented subsystems; their internal links are omitted where evidence is unavailable.
Main entry points: LockController.cpp Lock controller · main.ts MQTT and HTTP entry · state Access states · OtpService.ts OTP issuance and checks
Components 29
ESP32 firmware
- Keypad input
src/keypad/KeypadService.cpp - RFID reader
src/rfid/RfidService.cpp - Lock controller
src/state/LockController.cpp - Access states
src/state - OTP verification
src/otp/OtpService.cpp - Door actuator
src/door/DoorLock.cpp - Access indicators
src/indicator/AccessIndicator.cpp - LCD display
src/lcd/LcdService.cpp - Firmware MQTT
src/mqtt/MqttClient.cpp - Device configuration
src/config/ConfigManager.cpp - Wi-Fi setup
src/web/WebConfigService.cpp
Backend services
- MQTT and HTTP entry
server/src/main.ts - Card enrollment and checks
server/src/card/CardService.ts - Card store
server/src/card/CardStore.ts - OTP issuance and checks
server/src/otp/OtpService.ts - OTP generator
server/src/otp/OtpGenerator.ts - OTP store
server/src/otp/OtpStore.ts - OTP notifications
server/src/notify/OtpNotifier.ts - Email notifier
server/src/notify/EmailNotifier.ts - SMTP mailer
server/src/mail/SmtpMailer.ts
Web client
- Card management UI
client/components/CardManager.tsx - Card API client
client/lib/cards.ts
Camera features
- Camera capture and stream
src/camera/CameraService.cpp - Camera transport
src/serial/SerialCameraTransport.cpp - Camera upload and state
server/src/main.ts - Camera viewer
client/components/CameraViewer.tsx
Other components
- User
- MQTT broker
- Email service
Connections 28
- User → RFID reader: scans card
- RFID reader → Lock controller: dispatches UID
- User → Keypad input: enters code
- Keypad input → Lock controller: dispatches keys
- Lock controller → Access states: dispatches events
src/state/LockController.cpp - Lock controller → Firmware MQTT: requests OTP
src/state/LockController.cpp - Lock controller → LCD display: updates display
- Access states → OTP verification: verifies entry
- Access states → Door actuator: controls lock
- Access states → Access indicators: signals outcome
- Firmware MQTT → MQTT broker: publishes and subscribes
- MQTT broker → MQTT and HTTP entry: routes MQTT messages
- MQTT and HTTP entry → Card enrollment and checks: handles card requests
server/src/main.ts - Card enrollment and checks → Card store: reads and updates
server/src/card/CardService.ts - MQTT and HTTP entry → OTP issuance and checks: issues and verifies
server/src/main.ts - OTP issuance and checks → OTP generator: generates codes
server/src/otp/OtpService.ts - OTP issuance and checks → OTP store: stores and checks
server/src/otp/OtpService.ts - MQTT and HTTP entry → OTP notifications: notifies recipient
server/src/main.ts - OTP notifications → Email notifier: dispatches email
server/src/notify/EmailNotifier.ts - Email notifier → SMTP mailer: sends mail
server/src/notify/EmailNotifier.ts - SMTP mailer → Email service: delivers email
- User → Card management UI: manages cards
- Card management UI → Card API client: uses API client
- Card API client → MQTT and HTTP entry: requests card API
- User → Camera viewer: views camera
- Camera capture and stream → Camera transport: captures and sends frames
- Camera transport → Camera upload and state: uploads frames
- Camera upload and state → Camera viewer: serves stream and state