mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
refactor: split the transports into the modules GLOSSARY.md names
Code moves unchanged; only files and names change. - entryPoints/WebUiRoutes.cpp: registerWebUiRoutes(), the port 80 routes and the UI's files, with the helpers only they use. - entryPoints/ApiRoutes.cpp: registerApiRoutes(), the port 8081 routes. - entryPoints/Web.cpp keeps the servers' lifecycle, auth and the handlers both route sets call; entryPoints/WebRoutes.h is what the three share. - entryPoints/MQTT.* -> MqttConnection.*, class MQTTClass -> MqttConnection. - outputs/SomfyMqtt.cpp -> outputs/MqttPublisher.cpp. - outputs/Sockets.* -> outputs/SocketEmitter.*. The subscribe and unsubscribe lists (the latter repeated groups/+/direction/set) become MqttCommands' MQTT_COMMAND_TOPICS, and a native test checks the parser takes every topic in it. GLOSSARY.md gains MqttConnection and Change fan-out. 328 native tests. Flash: esp32devdbg +3,112 bytes (the routes are a second ArduinoJson file), esp32dev -2,336 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4c5bc01fe5
commit
a0ad301779
20 changed files with 1186 additions and 1066 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include <unity.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include "entryPoints/MqttCommands.h"
|
||||
|
||||
static shade_request_t req;
|
||||
|
|
@ -137,6 +138,14 @@ static void test_group_sunny_and_windy() {
|
|||
TEST_ASSERT_TRUE(parse("espsomfy/groups/2/windy/set", "1"));
|
||||
TEST_ASSERT_EQUAL_INT8(1, req.windy);
|
||||
}
|
||||
static void test_every_subscribed_topic_is_understood() {
|
||||
// What the connection subscribes to and what the parser takes can't drift.
|
||||
for(const char *pattern : MQTT_COMMAND_TOPICS) {
|
||||
std::string topic = std::string("espsomfy/") + pattern;
|
||||
topic.replace(topic.find('+'), 1, "3");
|
||||
TEST_ASSERT_TRUE_MESSAGE(parse(topic.c_str(), "1"), topic.c_str());
|
||||
}
|
||||
}
|
||||
static void test_groups_only_take_their_commands() {
|
||||
TEST_ASSERT_FALSE(parse("espsomfy/groups/2/target/set", "30"));
|
||||
TEST_ASSERT_FALSE(parse("espsomfy/groups/2/mypos/set", "30"));
|
||||
|
|
@ -161,5 +170,6 @@ int main(int argc, char **argv) {
|
|||
RUN_TEST(test_group_direction_and_sun_flag);
|
||||
RUN_TEST(test_group_sunny_and_windy);
|
||||
RUN_TEST(test_groups_only_take_their_commands);
|
||||
RUN_TEST(test_every_subscribed_topic_is_understood);
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue