How erwin-schrodinger-token/ewn-box-opener-espressif works
Project Type and Purpose
• The README details how to flash the firmware, connect via Wi-Fi, and configure the device. The project also supports board integration through community collaboration.
File Structure
• Top-level Directories:
• "src": Contains the core C++ firmware code (e.g., main.cpp, display, led, rgbled, websocket modules, param handling).
• "data": Contains web assets (HTML, CSS, JS, images) that power the captive portal and static configuration pages.
• "include" and "lib": Provide headers and perhaps additional libraries (check README in these folders for more details).
• ".github": Contains CI/CD workflows (build, SonarQube for code quality) indicating integration with automated testing and build systems.
• "test": Contains testing-related materials.
• Key patterns indicate a modular separation where each hardware function (display, LED, button) and network-related code (websocket) is encapsulated in its own module.
Important Architectural Details to Capture
a. Main Firmware Module:
• Central control running on the ESP board (refer to src/main.cpp).
• This module orchestrates the passing of control to the different submodules.
b. Hardware Interface Components:
• Button, LED, RGB LED modules (src/button.h, src/led.*, src/rgbled.*) that directly control the physical hardware.
• Control related modules (display.cpp, display.h, s3-display.h) that manage output.
• Parameter handling (param.cpp and param.h) for configuration data.
c. Network and Web Server Module:
• The captive portal functionality is enabled by the firmware hosting a web server serving static files from the "data" folder (HTML, CSS, JS files such as index.html, style.css, stats.js, etc.).
• The websocket communication (src/websocket.cpp, websockets.h) is used to enable real-time data exchange between the device and the client (for status updates or command/control).
d. Build and Integration Tools:
• PlatformIO (platformio.ini) is used for building, flashing, and board integration.
• CI workflows in .github (for building and code analysis through SonarQube) should be noted, though they are more for development than runtime architecture.
Relationships and Interactions
• The firmware (Main Control Unit) initiates and manages hardware interaction by invoking modules for LED, RGB LED, display, and button handling.
• When the device boots, it starts a web server that serves static content from the "data" directory, creating a captive portal.
• The user interacts with the captive portal through their browser, and this contact can trigger changes in configuration (handled by the param module) while the websocket module may push real-time updates.
• There is a clear data flow between user input via HTTP/websocket routes and the actual hardware control.
• The CI/CD processes (workflows in .github) support testing and quality assurance, ensuring that changes across modules are reliably integrated.