1 Commits

Author SHA1 Message Date
bionickatana e411c934d5 Adding diagnostics 2026-08-09 09:20:38 -06:00
5 changed files with 28 additions and 38 deletions
+2 -4
View File
@@ -14,9 +14,7 @@ board = esp32dev
framework = arduino framework = arduino
lib_deps = lib_deps =
WebSockets WebSockets
;board_build.f_cpu = 160000000L
;build_type = debug
; upload via OTA ; upload via OTA
;upload_protocol = espota upload_protocol = espota
;upload_port = 192.168.4.1 upload_port = 192.168.4.1
+19 -15
View File
@@ -13,25 +13,29 @@ void DiagnosticsState::update()
current.cpuFrequency = current.cpuFrequency =
ESP.getCpuFreqMHz(); ESP.getCpuFreqMHz();
Serial.print("#update: "); history[historyIndex] = current;
Serial.println(current.freeHeap);
Serial.println("Calling current from update"); historyIndex++;
getCurrent(); if(historyIndex >= DIAGNOSTIC_HISTORY_SIZE)
{
historyIndex = 0;
}
} }
DiagnosticSample DiagnosticsState::getCurrent() DiagnosticSample DiagnosticsState::getCurrent()
{ {
DiagnosticSample sample; return current;
sample.timestamp = current.timestamp; }
sample.freeHeap = current.freeHeap;
sample.minimumFreeHeap = current.minimumFreeHeap;
sample.cpuFrequency = current.cpuFrequency;
DiagnosticSample DiagnosticsState::getHistory(uint8_t index)
Serial.print("#getCurrent: "); {
Serial.println(sample.freeHeap); if(index >= DIAGNOSTIC_HISTORY_SIZE)
Serial.println(sample.timestamp); {
return sample; return current;
}
return history[index];
} }
+4 -4
View File
@@ -23,12 +23,12 @@ public:
DiagnosticSample getCurrent(); DiagnosticSample getCurrent();
//DiagnosticSample getHistory(uint8_t index); DiagnosticSample getHistory(uint8_t index);
private: private:
volatile DiagnosticSample current; DiagnosticSample current;
//DiagnosticSample history[DIAGNOSTIC_HISTORY_SIZE]; DiagnosticSample history[DIAGNOSTIC_HISTORY_SIZE];
//uint8_t historyIndex = 0; uint8_t historyIndex = 0;
}; };
+1 -13
View File
@@ -128,7 +128,6 @@ Firmware Version: <div id="firmware_version">Loading...</div>
void WebService::broadcastState() void WebService::broadcastState()
{ {
DiagnosticSample diagnostics = diagnosticsState.getCurrent(); DiagnosticSample diagnostics = diagnosticsState.getCurrent();
Serial.println(diagnostics.freeHeap);
String json = "{"; String json = "{";
// Opening system tag: // Opening system tag:
@@ -149,7 +148,6 @@ void WebService::broadcastState()
json += "\"free_heap\":\""; json += "\"free_heap\":\"";
json += diagnostics.freeHeap; json += diagnostics.freeHeap;
//json += ESP.getFreeHeap();
json += "\","; json += "\",";
json += "\"minimum_free_heap\":\""; json += "\"minimum_free_heap\":\"";
@@ -167,7 +165,7 @@ void WebService::broadcastState()
json += "}"; json += "}";
//Serial.println(json); Serial.println(json);
webSocket.broadcastTXT(json); webSocket.broadcastTXT(json);
} }
@@ -181,16 +179,6 @@ 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(); server.begin();
webSocket.begin(); webSocket.begin();
+2 -2
View File
@@ -22,8 +22,8 @@ private:
WebServer server; WebServer server;
WebSocketsServer webSocket; WebSocketsServer webSocket;
DashboardState& dashboardState; DashboardState dashboardState;
DiagnosticsState& diagnosticsState; DiagnosticsState diagnosticsState;
void handleWebSocketMessage(uint8_t clientNum, uint8_t *payload, size_t length); void handleWebSocketMessage(uint8_t clientNum, uint8_t *payload, size_t length);
void broadcastState(); void broadcastState();