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