mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-14 15:11:32 +10:00
Remove blocking config portal mode and refactor API
- Remove setConfigPortalBlocking() API and _configPortalIsBlocking member variable - Remove blocking while(1) loop from startConfigPortal() - Change startConfigPortal() return type from boolean to void - Change stopConfigPortal() return type from bool to void - Make stopConfigPortal() immediately shutdown portal (call shutdownConfigPortal() directly) - Remove unused portalAbortResult and portalTimeoutResult variables - Update all comments to remove blocking mode references - Simplify debug messages (remove 'non-blocking' references) - Update tests to remove setConfigPortalBlocking() calls - All 43 tests passing The config portal is now always non-blocking, requiring users to call process() periodically in their main loop. This aligns with the async web server architecture and simplifies the API.
This commit is contained in:
@@ -36,8 +36,6 @@ void test_configuration_setters() {
|
||||
wm.setShowDnsFields(false);
|
||||
|
||||
// Test portal behavior
|
||||
wm.setConfigPortalBlocking(true);
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setCaptivePortalEnable(true);
|
||||
wm.setCaptivePortalEnable(false);
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ void test_nonblocking_process() {
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Enable non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
wm.startConfigPortal("TestAP");
|
||||
|
||||
@@ -46,8 +44,6 @@ void test_client_check_setters() {
|
||||
wm.setAPClientCheck(true);
|
||||
wm.setAPClientCheck(false);
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal and verify it works with client check settings
|
||||
@@ -74,7 +70,6 @@ void test_nonblocking_timeout_behavior() {
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(2); // 2 second timeout
|
||||
wm.startConfigPortal("TestAP");
|
||||
|
||||
|
||||
@@ -8,12 +8,9 @@ void test_start_config_portal() {
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Use non-blocking mode so we can control when to stop
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal with SSID only
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
wm.startConfigPortal("TestAP");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
@@ -30,8 +27,6 @@ void test_start_config_portal_with_password() {
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal with SSID and password
|
||||
@@ -51,12 +46,9 @@ void test_start_config_portal_auto_name() {
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal without SSID (uses chip ID)
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
wm.startConfigPortal();
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
@@ -77,20 +69,16 @@ void test_stop_config_portal() {
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
wm.startConfigPortal("TestAP");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
delay(100);
|
||||
|
||||
// Stop portal
|
||||
bool stopped = wm.stopConfigPortal();
|
||||
TEST_ASSERT_TRUE(stopped);
|
||||
wm.stopConfigPortal();
|
||||
TEST_ASSERT_FALSE(wm.getConfigPortalActive());
|
||||
|
||||
Serial.println("[TEST] stopConfigPortal() test completed successfully");
|
||||
@@ -101,11 +89,8 @@ void test_config_portal_infrastructure() {
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
wm.startConfigPortal("TestAP");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
@@ -176,12 +161,9 @@ void test_config_portal_multiple_start_stop() {
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// First cycle
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
wm.startConfigPortal("TestAP1");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
delay(100);
|
||||
@@ -212,21 +194,17 @@ void test_config_portal_already_active() {
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
wm.startConfigPortal("TestAP");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
delay(100);
|
||||
|
||||
// Try to start again (should fail/return false)
|
||||
bool started2 = wm.startConfigPortal("TestAP2");
|
||||
TEST_ASSERT_FALSE(started2); // Should return false when already active
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive()); // Still active
|
||||
// Try to start again (should silently fail when already active)
|
||||
wm.startConfigPortal("TestAP2");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive()); // Still active with original AP name
|
||||
|
||||
wm.stopConfigPortal();
|
||||
|
||||
@@ -238,8 +216,6 @@ void test_get_config_portal_ssid() {
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start with known SSID
|
||||
|
||||
@@ -16,8 +16,6 @@ void test_set_ap_static_ip_config() {
|
||||
// Set AP static IP
|
||||
wm.setAPStaticIPConfig(ip, gw, sn);
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal and verify IP is actually set
|
||||
@@ -72,11 +70,8 @@ void test_ap_static_ip_application() {
|
||||
|
||||
wm.setAPStaticIPConfig(customIP, customGW, customSN);
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
wm.startConfigPortal("TestAP");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user