$ show rednblkx/HomeKey-ESP32
This repository implements a DIY smart lock controller for ESP32 hardware, enabling Apple HomeKey NFC authentication, HomeKit integration, and MQTT connectivity for Home Assistant. The architecture is a hybrid embedded system: a C++ backend built on ESP-IDF (FreeRTOS) handles hardware interaction (NFC, GPIO, Ethernet) and protocol stacks (HomeSpan, mbedTLS), while a Svelte 5 frontend hosted on the device's LittleFS provides a web-based configuration and monitoring interface. The system manages configuration persistence in NVS using MessagePack/JSON serialization and streams real-time logs via WebSocket. Engineering quality is high, featuring RAII wrappers for memory safety in C++, template-based configuration management, and a decoupled event-loop architecture. However, the codebase carries significant security debt, explicitly acknowledging the lack of flash encryption and plain-text password storage in configuration. Hardware support is fragmented across ESP32 variants and NFC modules, requiring hardcoded pin presets that limit portability. Despite 52 open issues, the recent commit activity and modern tech stack (ESP-IDF 5.x, Svelte 5) indicate active development.
The LLM identified 4 files worth highlighting for reuse:
Implements a template-based configuration manager that handles NVS load/save operations with type-safe access. It abstracts JSON and MessagePack serialization, providing a reusable pattern for persisting complex device settings without boilerplate. The design ensures validation and atomic updates, making it safe to extract for other embedded projects requiring robust config storage.
Provides RAII-based GPIO pin management to prevent conflicts in embedded systems. It tracks pin ownership and ensures exclusive allocation, automatically releasing pins on scope exit. This pattern is critical for hardware safety and can be reused in any ESP32 project to avoid pin contention bugs.
Wraps ESP-IDF native events into a decoupled pub/sub system. It allows modules (NFC, Lock, MQTT) to communicate without direct dependencies, reducing coupling and improving testability. The implementation demonstrates non-obvious skill in managing FreeRTOS tasks and event queues for concurrent hardware operations.
Manages reactive device state (uptime, WiFi, lock status) using Svelte 5 Runes. It integrates with the WebSocket service to stream telemetry from the backend to the UI. The store pattern is clean and parameterized, making it easily adaptable for other IoT dashboards requiring real-time status updates.