diff --git a/platformio.ini b/platformio.ini index cd2ac77..8b4c1c2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,7 +14,8 @@ board = esp32dev framework = arduino lib_deps = WebSockets +;build_type = debug ; upload via OTA -upload_protocol = espota -upload_port = 192.168.4.1 +;upload_protocol = espota +;upload_port = 192.168.4.1 diff --git a/src/core/diagnostics_state.cpp b/src/core/diagnostics_state.cpp index 4f4221d..6310461 100644 --- a/src/core/diagnostics_state.cpp +++ b/src/core/diagnostics_state.cpp @@ -13,29 +13,37 @@ void DiagnosticsState::update() current.cpuFrequency = ESP.getCpuFreqMHz(); - history[historyIndex] = current; - - historyIndex++; - if(historyIndex >= DIAGNOSTIC_HISTORY_SIZE) - { - historyIndex = 0; - } + //history[historyIndex] = current; + // + //historyIndex++; + //if(historyIndex >= DIAGNOSTIC_HISTORY_SIZE) + //{ + // historyIndex = 0; + //} + Serial.print("#update: "); + Serial.println(current.freeHeap); + Serial.println("Calling current from update"); + getCurrent(); + } DiagnosticSample DiagnosticsState::getCurrent() { + Serial.print("#getCurrent: "); + Serial.println(current.freeHeap); + Serial.println(current.timestamp); return current; } -DiagnosticSample DiagnosticsState::getHistory(uint8_t index) -{ - if(index >= DIAGNOSTIC_HISTORY_SIZE) - { - return current; - } - return history[index]; -} +//DiagnosticSample DiagnosticsState::getHistory(uint8_t index) +//{ +// if(index >= DIAGNOSTIC_HISTORY_SIZE) +// { +// return current; +// } +// return history[index]; +//} diff --git a/src/core/diagnostics_state.h b/src/core/diagnostics_state.h index c5873d6..f808e42 100644 --- a/src/core/diagnostics_state.h +++ b/src/core/diagnostics_state.h @@ -23,12 +23,12 @@ public: DiagnosticSample getCurrent(); - DiagnosticSample getHistory(uint8_t index); + //DiagnosticSample getHistory(uint8_t index); private: DiagnosticSample current; - DiagnosticSample history[DIAGNOSTIC_HISTORY_SIZE]; - uint8_t historyIndex = 0; + //DiagnosticSample history[DIAGNOSTIC_HISTORY_SIZE]; + //uint8_t historyIndex = 0; }; diff --git a/src/services/web_service.cpp b/src/services/web_service.cpp index d10090d..defc279 100644 --- a/src/services/web_service.cpp +++ b/src/services/web_service.cpp @@ -128,6 +128,7 @@ Firmware Version:
Loading...
void WebService::broadcastState() { DiagnosticSample diagnostics = diagnosticsState.getCurrent(); + Serial.println(diagnostics.freeHeap); String json = "{"; // Opening system tag: @@ -148,6 +149,7 @@ void WebService::broadcastState() json += "\"free_heap\":\""; json += diagnostics.freeHeap; + //json += ESP.getFreeHeap(); json += "\","; json += "\"minimum_free_heap\":\""; @@ -165,7 +167,7 @@ void WebService::broadcastState() json += "}"; - Serial.println(json); + //Serial.println(json); webSocket.broadcastTXT(json); } @@ -179,6 +181,16 @@ void WebService::begin() { ); }); + #ifdef DEBUGGING + // Prints out paths that are requested but not found. + server.onNotFound([this]() { + Serial.print("HTTP not found: "); + Serial.println(server.uri()); + + server.send(404, "text/plain", "Not found"); + }); + #endif + server.begin(); webSocket.begin();