DTC in WebUI now handled via Websocket
This commit is contained in:
@@ -67,7 +67,15 @@ void initWebUI()
|
||||
void Webserver_Process()
|
||||
{
|
||||
#ifdef FEATURE_ENABLE_WEBSOCKETS
|
||||
static uint32_t previousMillis = 0;
|
||||
|
||||
webSocket.cleanupClients();
|
||||
|
||||
if ((webSocket.count() > 0) && (millis() - previousMillis >= 10000))
|
||||
{
|
||||
Websocket_RefreshClientData_DTCs();
|
||||
previousMillis = millis();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -161,58 +169,6 @@ String processor(const String &var)
|
||||
#else
|
||||
return "hidden";
|
||||
#endif
|
||||
if (var == "SHOW_DTC_TABLE")
|
||||
return globals.hasDTC ? "" : "hidden";
|
||||
|
||||
if (var == "DTC_TABLE")
|
||||
{
|
||||
String temp = "";
|
||||
char buff_timestamp[16]; // Format: DD-hh:mm:ss:xxx
|
||||
|
||||
for (uint32_t i = 0; i < MAX_DTC_STORAGE; i++)
|
||||
{
|
||||
if (DTCStorage[i].Number < DTC_LAST_DTC)
|
||||
{
|
||||
sprintf(buff_timestamp, "%02d-%02d:%02d:%02d:%03d",
|
||||
DTCStorage[i].timestamp / 86400000, // Days
|
||||
DTCStorage[i].timestamp / 360000 % 24, // Hours
|
||||
DTCStorage[i].timestamp / 60000 % 60, // Minutes
|
||||
DTCStorage[i].timestamp / 1000 % 60, // Seconds
|
||||
DTCStorage[i].timestamp % 1000); // milliseconds
|
||||
|
||||
temp = temp + "<tr data-dtc=" + String(DTCStorage[i].Number);
|
||||
temp = temp + " data-debugval=" + String(DTCStorage[i].debugVal) + "><td>" + String(buff_timestamp);
|
||||
temp = temp + "</td><td>" + String(DTCStorage[i].Number) + "</td><td>";
|
||||
temp = temp + "<img src=static/img/";
|
||||
switch (getSeverityForDTC(DTCStorage[i].Number))
|
||||
{
|
||||
case DTC_CRITICAL:
|
||||
temp = temp + "critical";
|
||||
break;
|
||||
case DTC_WARN:
|
||||
temp = temp + "warn";
|
||||
break;
|
||||
case DTC_INFO:
|
||||
temp = temp + "info";
|
||||
break;
|
||||
case DTC_NONE:
|
||||
temp = temp + "none";
|
||||
break;
|
||||
}
|
||||
temp = temp + ".png></td><td>";
|
||||
|
||||
if (DTCStorage[i].active == DTC_ACTIVE)
|
||||
temp = temp + "active";
|
||||
else if (DTCStorage[i].active == DTC_PREVIOUS)
|
||||
temp = temp + "previous";
|
||||
else
|
||||
temp = temp + "none";
|
||||
|
||||
temp = temp + "</td></tr>";
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
if (var == "SOURCE_SELECT_OPTIONS")
|
||||
{
|
||||
@@ -685,6 +641,33 @@ void Websocket_HandleMessage(void *arg, uint8_t *data, size_t len)
|
||||
|
||||
void Websocket_PushLiveDebug(String Message)
|
||||
{
|
||||
webSocket.textAll(Message + "\n");
|
||||
webSocket.textAll("DEBUG:" + Message);
|
||||
}
|
||||
|
||||
void Websocket_RefreshClientData_DTCs()
|
||||
{
|
||||
String temp = "";
|
||||
|
||||
// Build DTC-String
|
||||
if (globals.hasDTC != true)
|
||||
{
|
||||
temp = "DTC:" + String(DTC_NO_DTC) + ";";
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = "DTC:";
|
||||
for (uint32_t i = 0; i < MAX_DTC_STORAGE; i++)
|
||||
{
|
||||
if (DTCStorage[i].Number < DTC_LAST_DTC)
|
||||
{
|
||||
temp = temp + String(DTCStorage[i].timestamp) + ",";
|
||||
temp = temp + String(DTCStorage[i].Number) + ",";
|
||||
temp = temp + String(getSeverityForDTC(DTCStorage[i].Number)) + ",";
|
||||
temp = temp + String(DTCStorage[i].active) + ",";
|
||||
temp = temp + String(DTCStorage[i].debugVal) + ";";
|
||||
}
|
||||
}
|
||||
}
|
||||
webSocket.textAll(temp);
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user