Refactor WiFiManager: extract server and handlers into separate modules

- Move server lifecycle management to WiFiManagerServer
- Move HTTP handlers and rendering to WiFiManagerHandlers
- Move DEBUG_WM template definitions to WiFiManagerDebug
- Implement lazy initialization of server manager to save memory
- Add proper cleanup in destructor and on multiple createServer calls
- Update tests to use getServer() and getDNSServer() accessors
This commit is contained in:
2025-11-15 22:22:36 +10:00
parent 1788aa3c4a
commit 9cd5f62f9b
14 changed files with 1777 additions and 1753 deletions
@@ -15,13 +15,13 @@ void test_dns_server_created() {
// Wait for DNS server to be created
unsigned long start = millis();
while (!wm.dnsServer && (millis() - start < 1000)) {
while (!wm.getDNSServer() && (millis() - start < 1000)) {
wm.process();
delay(10);
}
// DNS server should be created when portal starts
TEST_ASSERT_NOT_NULL(wm.dnsServer);
TEST_ASSERT_NOT_NULL(wm.getDNSServer());
wm.stopConfigPortal();
@@ -40,13 +40,13 @@ void test_dns_server_cleanup() {
// Wait for DNS server to be created
unsigned long start = millis();
while (!wm.dnsServer && (millis() - start < 1000)) {
while (!wm.getDNSServer() && (millis() - start < 1000)) {
wm.process();
delay(10);
}
// Verify DNS server exists
TEST_ASSERT_NOT_NULL(wm.dnsServer);
TEST_ASSERT_NOT_NULL(wm.getDNSServer());
// Stop portal
wm.stopConfigPortal();
@@ -72,11 +72,11 @@ void test_dns_server_lifecycle_cycles() {
wm.process();
unsigned long start = millis();
while (!wm.dnsServer && (millis() - start < 1000)) {
while (!wm.getDNSServer() && (millis() - start < 1000)) {
wm.process();
delay(10);
}
TEST_ASSERT_NOT_NULL(wm.dnsServer);
TEST_ASSERT_NOT_NULL(wm.getDNSServer());
wm.stopConfigPortal();
wm.process();
@@ -87,11 +87,11 @@ void test_dns_server_lifecycle_cycles() {
wm.process();
start = millis();
while (!wm.dnsServer && (millis() - start < 1000)) {
while (!wm.getDNSServer() && (millis() - start < 1000)) {
wm.process();
delay(10);
}
TEST_ASSERT_NOT_NULL(wm.dnsServer);
TEST_ASSERT_NOT_NULL(wm.getDNSServer());
wm.stopConfigPortal();
wm.process();