diff --git a/src/CrossPointWebServer.cpp b/src/CrossPointWebServer.cpp index 9bc0bcd..c63ee28 100644 --- a/src/CrossPointWebServer.cpp +++ b/src/CrossPointWebServer.cpp @@ -113,7 +113,7 @@ void CrossPointWebServer::stop() { Serial.printf("[%lu] [WEB] STOP INITIATED - setting running=false first\n", millis()); running = false; // Set this FIRST to prevent handleClient from using server - + Serial.printf("[%lu] [WEB] [MEM] Free heap before stop: %d bytes\n", millis(), ESP.getFreeHeap()); // Add delay to allow any in-flight handleClient() calls to complete @@ -140,24 +140,24 @@ void CrossPointWebServer::stop() { void CrossPointWebServer::handleClient() { static unsigned long lastDebugPrint = 0; - + // Check running flag FIRST before accessing server if (!running) { return; } - + // Double-check server pointer is valid if (!server) { Serial.printf("[%lu] [WEB] WARNING: handleClient called with null server!\n", millis()); return; } - + // Print debug every 10 seconds to confirm handleClient is being called if (millis() - lastDebugPrint > 10000) { Serial.printf("[%lu] [WEB] handleClient active, server running on port %d\n", millis(), port); lastDebugPrint = millis(); } - + server->handleClient(); } diff --git a/src/activities/home/HomeActivity.h b/src/activities/home/HomeActivity.h index 6439204..5dd26ec 100644 --- a/src/activities/home/HomeActivity.h +++ b/src/activities/home/HomeActivity.h @@ -23,7 +23,10 @@ class HomeActivity final : public Activity { public: explicit HomeActivity(GfxRenderer& renderer, InputManager& inputManager, const std::function& onReaderOpen, const std::function& onSettingsOpen, const std::function& onFileTransferOpen) - : Activity(renderer, inputManager), onReaderOpen(onReaderOpen), onSettingsOpen(onSettingsOpen), onFileTransferOpen(onFileTransferOpen) {} + : Activity(renderer, inputManager), + onReaderOpen(onReaderOpen), + onSettingsOpen(onSettingsOpen), + onFileTransferOpen(onFileTransferOpen) {} void onEnter() override; void onExit() override; void loop() override; diff --git a/src/activities/network/CrossPointWebServerActivity.cpp b/src/activities/network/CrossPointWebServerActivity.cpp index fe572c9..7b870e8 100644 --- a/src/activities/network/CrossPointWebServerActivity.cpp +++ b/src/activities/network/CrossPointWebServerActivity.cpp @@ -37,9 +37,8 @@ void CrossPointWebServerActivity::onEnter() { // Launch WiFi selection subactivity Serial.printf("[%lu] [WEBACT] Launching WifiSelectionActivity...\n", millis()); - wifiSelection.reset(new WifiSelectionActivity(renderer, inputManager, [this](bool connected) { - onWifiSelectionComplete(connected); - })); + wifiSelection.reset(new WifiSelectionActivity(renderer, inputManager, + [this](bool connected) { onWifiSelectionComplete(connected); })); wifiSelection->onEnter(); } @@ -67,12 +66,12 @@ void CrossPointWebServerActivity::onExit() { // Disconnect WiFi gracefully Serial.printf("[%lu] [WEBACT] Disconnecting WiFi (graceful)...\n", millis()); WiFi.disconnect(false); // false = don't erase credentials, send disconnect frame - delay(100); // Allow disconnect frame to be sent - + delay(100); // Allow disconnect frame to be sent + Serial.printf("[%lu] [WEBACT] Setting WiFi mode OFF...\n", millis()); WiFi.mode(WIFI_OFF); delay(100); // Allow WiFi hardware to fully power down - + Serial.printf("[%lu] [WEBACT] [MEM] Free heap after WiFi disconnect: %d bytes\n", millis(), ESP.getFreeHeap()); // Acquire mutex before deleting task @@ -104,7 +103,7 @@ void CrossPointWebServerActivity::onWifiSelectionComplete(bool connected) { // Get connection info before exiting subactivity connectedIP = wifiSelection->getConnectedIP(); connectedSSID = WiFi.SSID().c_str(); - + // Exit the wifi selection subactivity wifiSelection->onExit(); wifiSelection.reset(); @@ -119,13 +118,13 @@ void CrossPointWebServerActivity::onWifiSelectionComplete(bool connected) { void CrossPointWebServerActivity::startWebServer() { Serial.printf("[%lu] [WEBACT] Starting web server...\n", millis()); - + crossPointWebServer.begin(); - + if (crossPointWebServer.isRunning()) { state = WebServerActivityState::SERVER_RUNNING; Serial.printf("[%lu] [WEBACT] Web server started successfully\n", millis()); - + // Force an immediate render since we're transitioning from a subactivity // that had its own rendering task. We need to make sure our display is shown. xSemaphoreTake(renderingMutex, portMAX_DELAY); diff --git a/src/activities/network/CrossPointWebServerActivity.h b/src/activities/network/CrossPointWebServerActivity.h index f9e4509..31946fb 100644 --- a/src/activities/network/CrossPointWebServerActivity.h +++ b/src/activities/network/CrossPointWebServerActivity.h @@ -12,9 +12,9 @@ // Web server activity states enum class WebServerActivityState { - WIFI_SELECTION, // WiFi selection subactivity is active - SERVER_RUNNING, // Web server is running and handling requests - SHUTTING_DOWN // Shutting down server and WiFi + WIFI_SELECTION, // WiFi selection subactivity is active + SERVER_RUNNING, // Web server is running and handling requests + SHUTTING_DOWN // Shutting down server and WiFi }; /** @@ -38,7 +38,7 @@ class CrossPointWebServerActivity final : public Activity { // Server status std::string connectedIP; std::string connectedSSID; - + // Performance monitoring unsigned long lastHandleClientTime = 0; @@ -53,7 +53,7 @@ class CrossPointWebServerActivity final : public Activity { public: explicit CrossPointWebServerActivity(GfxRenderer& renderer, InputManager& inputManager, - const std::function& onGoBack) + const std::function& onGoBack) : Activity(renderer, inputManager), onGoBack(onGoBack) {} void onEnter() override; void onExit() override; diff --git a/src/activities/network/WifiSelectionActivity.h b/src/activities/network/WifiSelectionActivity.h index a6b3c25..e7b12ae 100644 --- a/src/activities/network/WifiSelectionActivity.h +++ b/src/activities/network/WifiSelectionActivity.h @@ -40,7 +40,7 @@ enum class WifiSelectionState { * - Allow selection and launch KeyboardEntryActivity for password if needed * - Save the password if requested * - Call onComplete callback when connected or cancelled - * + * * The onComplete callback receives true if connected successfully, false if cancelled. */ class WifiSelectionActivity final : public Activity { @@ -97,12 +97,12 @@ class WifiSelectionActivity final : public Activity { public: explicit WifiSelectionActivity(GfxRenderer& renderer, InputManager& inputManager, - const std::function& onComplete) + const std::function& onComplete) : Activity(renderer, inputManager), onComplete(onComplete) {} void onEnter() override; void onExit() override; void loop() override; - + // Get the IP address after successful connection const std::string& getConnectedIP() const { return connectedIP; } }; diff --git a/src/activities/util/KeyboardEntryActivity.cpp b/src/activities/util/KeyboardEntryActivity.cpp index 8db7b94..40d6fed 100644 --- a/src/activities/util/KeyboardEntryActivity.cpp +++ b/src/activities/util/KeyboardEntryActivity.cpp @@ -10,15 +10,12 @@ const char* const KeyboardEntryActivity::keyboard[NUM_ROWS] = { // Keyboard layouts - uppercase/symbols const char* const KeyboardEntryActivity::keyboardShift[NUM_ROWS] = {"~!@#$%^&*()_+", "QWERTYUIOP{}|", "ASDFGHJKL:\"", - "ZXCVBNM<>?", "^ _____?", "^ _____