diff --git a/src/netman.h b/src/netman.h index e0dd843..4778398 100644 --- a/src/netman.h +++ b/src/netman.h @@ -7,7 +7,7 @@ #include // Constants for the HTML pages and config file -static const String beginHtml = "AP Configure

"; +static const String beginHtml = "SmartCube Configure

Configure AP


"; static const String endHtml = "
"; static const String configFile = "/netman"; @@ -104,19 +104,48 @@ bool netman::tryConnect() { } // Attempt to connect to a specific SSID with timeout +// Attempt to connect to a specific SSID with timeout and dot animation bool netman::tryConnectToSsid(const char* ssid, const char* pass) { WiFi.begin(ssid, pass); unsigned long start = millis(); - display.println("Connecting to " + String(ssid) + "..."); + // Clear display and set initial message + display.clearDisplay(); + display.setCursor(0, 0); + display.println("Connecting to SSID:"); + display.println(String(ssid)); + display.display(); + + int dotCount = 0; while (millis() - start < connectionTimeout) { delay(500); + + // Check WiFi connection status if (WiFi.status() == WL_CONNECTED) { + // Success message + display.clearDisplay(); + display.setCursor(0, 0); display.println("Connected!"); + display.display(); return true; } + + // Animate by adding dots up to three, then reset + display.setCursor(0, 20); + display.print("Connecting"); + for (int i = 0; i < dotCount; i++) { + display.print("."); + } + display.display(); + + dotCount = (dotCount + 1) % 4; // Cycle dot count from 0 to 3 } + + // Connection failed + display.clearDisplay(); + display.setCursor(0, 0); display.println("Connection failed."); + display.display(); WiFi.disconnect(); return false; }