|
|
|
|
@@ -144,4 +144,29 @@ frontend/dist/ firmware.bin
|
|
|
|
|
|
|
|
|
|
## 9. Summary
|
|
|
|
|
|
|
|
|
|
## 9. Summary
|
|
|
|
|
|
|
|
|
|
We use **esp_http_server + cJSON + LittleFS** — all standard ESP-IDF components — to serve the frontend and expose a REST API. A **LittleFS partition** stores frontend files separately from firmware, with a **Kconfig toggle** to skip frontend flashing during backend development. The API is structured as **modular handler files** under `api/` for clean scalability.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 10. Implementation Results
|
|
|
|
|
|
|
|
|
|
*Added 2026-03-03 after implementation and integration was completed.*
|
|
|
|
|
|
|
|
|
|
### Refactoring & Architecture Outcomes
|
|
|
|
|
- **Unity Build Pattern**: Successfully adopted for the HTTP server (`http_server.cpp` includes `.cpp` API handlers). This simplified the build process, reduced include complexity, and resolved multiple redefinition and linkage errors without needing complex CMake modifications.
|
|
|
|
|
- **State Management**: Created a centralized `appstate.hpp` to cleanly share global state (`g_Ethernet_Initialized`, `g_Wifi_Initialized`) across the project, eliminating ad-hoc `extern` declarations.
|
|
|
|
|
|
|
|
|
|
### API Capabilities & Analytics
|
|
|
|
|
- **System Info (`GET /api/system/info`)**: Returns real-time JSON payload containing chip type, free heap, uptime, firmware version, and connection status. Data payload is lightweight (~110 bytes).
|
|
|
|
|
- **Remote Reboot (`POST /api/system/reboot`)**: Initiates an async reboot using `esp_timer` with a 1-second delay, allowing the backend to flush a successful `200 OK` JSON response to the client before the processor halts.
|
|
|
|
|
- **CORS Support**: Implemented `Access-Control-Allow-Origin: *` headers for all API GET and POST responses, along with an `OPTIONS` preflight handler, to support seamless local UI development against the ESP32.
|
|
|
|
|
|
|
|
|
|
### Stability & Performance Fixes
|
|
|
|
|
- **Persistent Daemon**: Addressed an issue where `app_main` executed to completion immediately, causing the web server daemon to drop. Implemented a non-blocking `vTaskDelay` keep-alive loop to persist the application state and keep the HTTP server listening indefinitely without spinning the CPU.
|
|
|
|
|
- **Static File Fallbacks**: The LittleFS static file handler correctly falls back to `index.html` (and `.gz` variants) to seamlessly support Svelte's Single Page Application (SPA) routing patterns.
|
|
|
|
|
|
|
|
|
|
### Observability Benchmarks
|
|
|
|
|
- **Heap Usage**: The system info endpoint natively tracks free heap availability. Observed typical runtime footprint leaves roughly **247 KB free heap** with active WiFi, API handling, and active HTTP server routing.
|
|
|
|
|
- **API Response Latency**: The minimalist handler approach results in near-instantaneous JSON responses (milliseconds), effortlessly supporting the frontend dashboard's 5-second polling interval without blocking the ESP32-S3 network stack.
|
|
|
|
|
|