refactor: move the transports into entryPoints and outputs

The HTTP servers and MQTT command handling go to src/entryPoints/, the
socket emitter and the MQTT and socket output of shades, groups and rooms
to src/outputs/. GLOSSARY.md names what they become once split:
WebUiRoutes, ApiRoutes and MqttCommands in, MqttPublisher and
SocketEmitter out.

Only files and include paths change. esp32devdbg flash goes from
1,546,405 to 1,546,257 bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-15 19:41:49 +02:00
parent 7396786b8c
commit e624a4177d
16 changed files with 42 additions and 15 deletions

View file

@ -51,3 +51,29 @@ The per-shade switch that lets the sun move a shade. While it is on, lasting sun
**Extend / retract** **Extend / retract**
Where the weather sends a shade: extend to its favorite, or fully when it has none; retract fully. A tilt-only shade extends and retracts its tilt, every other shade its lift. Where the weather sends a shade: extend to its favorite, or fully when it has none; retract fully. A tilt-only shade extends and retracts its tilt, every other shade its lift.
## Entry points and outputs
**Entry point**
Where a request from outside reaches the firmware: an HTTP route, an MQTT command topic or a frame received from a remote.
_Avoid_: controller (it already names the owner of the shade list and the `/controller` read)
**WebUiRoutes**
The HTTP routes on port 80 that the config web UI calls, plus the UI's own files.
_Avoid_: WebUiController, Web
**ApiRoutes**
The HTTP routes on port 8081 that integrations such as Home Assistant call.
_Avoid_: WebApiController
**MqttCommands**
The MQTT topics ending in `/set` that command a shade or group.
_Avoid_: MQTTController
**MqttPublisher**
What sends the state of rooms, shades and groups, and the Home Assistant discovery config, to the MQTT broker.
_Avoid_: MQTTController
**SocketEmitter**
What pushes state events to WebSocket clients on port 8080. A client can only join or leave a room; it sends no commands.
_Avoid_: WebSocketController

View file

@ -3,7 +3,7 @@
## Concurrent mutation during chunked `/controller` response ## Concurrent mutation during chunked `/controller` response
**Status:** open **Status:** open
**Introduced:** 2026-04-19, alongside the chunked-response conversion of `/controller` (see [`ControllerChunker` in src/Web.cpp](../src/Web.cpp) and the original crash report about `cbuf::resize` aborting `async_tcp`). **Introduced:** 2026-04-19, alongside the chunked-response conversion of `/controller` (see [`ControllerChunker` in src/entryPoints/Web.cpp](../src/entryPoints/Web.cpp) and the original crash report about `cbuf::resize` aborting `async_tcp`).
### Summary ### Summary
@ -42,7 +42,7 @@ The new `ControllerChunker` reads state as the response drains. On a slow link o
## Oversized `/controller` items are left out ## Oversized `/controller` items are left out
**Status:** open **Status:** open
**Location:** `ControllerChunker::overflowed` in [src/Web.cpp](../src/Web.cpp). **Location:** `ControllerChunker::overflowed` in [src/entryPoints/Web.cpp](../src/entryPoints/Web.cpp).
### Summary ### Summary
@ -67,7 +67,7 @@ A shade with every linked remote populated is about 1.5 KB today, so nothing ove
## Large websocket events are dropped ## Large websocket events are dropped
**Status:** open **Status:** open
**Location:** [`JsonSockEvent` in src/WResp.cpp](../src/WResp.cpp), buffer `g_response[MAX_SOCK_RESPONSE]` (2048 bytes) in [src/Sockets.cpp](../src/Sockets.cpp). **Location:** [`JsonSockEvent` in src/WResp.cpp](../src/WResp.cpp), buffer `g_response[MAX_SOCK_RESPONSE]` (2048 bytes) in [src/outputs/Sockets.cpp](../src/outputs/Sockets.cpp).
### Summary ### Summary

View file

@ -2,6 +2,7 @@
**Status:** done. Phases 0 and 1 in `bbfb23e`..`505108c`, phase 2 in `0eb0e63`..`a176017` (2026-10-13). **Status:** done. Phases 0 and 1 in `bbfb23e`..`505108c`, phase 2 in `0eb0e63`..`a176017` (2026-10-13).
**Written:** 2026-10-13, against commit `4544eb6` on `fix/live-bugs`. Line numbers in the analysis below refer to that commit. The code now lives in the files listed under [Phase 1](#phase-1-split-the-file-by-concern). **Written:** 2026-10-13, against commit `4544eb6` on `fix/live-bugs`. Line numbers in the analysis below refer to that commit. The code now lives in the files listed under [Phase 1](#phase-1-split-the-file-by-concern).
Since then `SomfyMqtt.cpp` and `SomfyEvents.cpp` have moved to `src/outputs/`.
## Why ## Why

View file

@ -13,11 +13,11 @@ static inline void safe_wdt_reset() {
} }
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "ESPNetwork.h" #include "ESPNetwork.h"
#include "Web.h" #include "entryPoints/Web.h"
#include "Sockets.h" #include "outputs/Sockets.h"
#include "Utils.h" #include "Utils.h"
#include "SSDP.h" #include "SSDP.h"
#include "MQTT.h" #include "entryPoints/MQTT.h"
static const char *TAG = "Network"; static const char *TAG = "Network";

View file

@ -8,9 +8,9 @@
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "GitOTA.h" #include "GitOTA.h"
#include "Utils.h" #include "Utils.h"
#include "Sockets.h" #include "outputs/Sockets.h"
#include "Somfy.h" #include "Somfy.h"
#include "Web.h" #include "entryPoints/Web.h"
#include "WResp.h" #include "WResp.h"
#include "ESPNetwork.h" #include "ESPNetwork.h"

View file

@ -4,11 +4,11 @@
#include <esp_task_wdt.h> #include <esp_task_wdt.h>
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "ESPNetwork.h" #include "ESPNetwork.h"
#include "Web.h" #include "entryPoints/Web.h"
#include "Sockets.h" #include "outputs/Sockets.h"
#include "Utils.h" #include "Utils.h"
#include "Somfy.h" #include "Somfy.h"
#include "MQTT.h" #include "entryPoints/MQTT.h"
#include "GitOTA.h" #include "GitOTA.h"
#include "esp_core_dump.h" #include "esp_core_dump.h"
#include "esp_system.h" #include "esp_system.h"

View file

@ -10,7 +10,7 @@
#include "Utils.h" #include "Utils.h"
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "Somfy.h" #include "Somfy.h"
#include "Sockets.h" #include "outputs/Sockets.h"
static const char *TAG = "Somfy"; static const char *TAG = "Somfy";

View file

@ -3,7 +3,7 @@
#include <stdint.h> #include <stdint.h>
#include "SomfyFrame.h" #include "SomfyFrame.h"
// Commands the web servers hand to the main loop (src/Web.cpp). Kept free of // Commands the web servers hand to the main loop (src/entryPoints/Web.cpp). Kept free of
// the web server and FreeRTOS so it can be unit tested on the PC // the web server and FreeRTOS so it can be unit tested on the PC
// (pio test -e native). // (pio test -e native).

View file

@ -1,7 +1,7 @@
#include <esp_task_wdt.h> #include <esp_task_wdt.h>
#include "Somfy.h" #include "Somfy.h"
#include "Sockets.h" #include "Sockets.h"
#include "MQTT.h" #include "entryPoints/MQTT.h"
extern SomfyShadeController somfy; extern SomfyShadeController somfy;
extern SocketEmitter sockEmit; extern SocketEmitter sockEmit;

View file

@ -2,7 +2,7 @@
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "Somfy.h" #include "Somfy.h"
#include "Sockets.h" #include "Sockets.h"
#include "MQTT.h" #include "entryPoints/MQTT.h"
extern SomfyShadeController somfy; extern SomfyShadeController somfy;
extern SocketEmitter sockEmit; extern SocketEmitter sockEmit;