Compare commits
No commits in common. "bc2c19dad1abf622b55f4f779b9bd6e21d3d1c41" and "d524b919fde9bdbd5238addc816c10c8bca1ea09" have entirely different histories.
bc2c19dad1
...
d524b919fd
@ -28,9 +28,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Connection-Overlay -->
|
<!-- Connection-Overlay -->
|
||||||
<!-- Notification-Container -->
|
|
||||||
<div id="notification-container" class="notification-container"></div>
|
|
||||||
<!-- Notification-Container -->
|
|
||||||
<nav class="navbar fixed-top navbar-dark bg-primary" id="navbar1">
|
<nav class="navbar fixed-top navbar-dark bg-primary" id="navbar1">
|
||||||
<a class="navbar-brand" href="#">
|
<a class="navbar-brand" href="#">
|
||||||
<img src="static/img/logo.png" width="30" height="30" class="d-inline-block align-top mr-1" alt="">
|
<img src="static/img/logo.png" width="30" height="30" class="d-inline-block align-top mr-1" alt="">
|
||||||
@ -125,7 +122,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col text-center">
|
<div class="col text-center">
|
||||||
<button id="resettank" class="btn-wsevent confirm btn btn-outline-primary ml-2">Tank zurücksetzen</button>
|
<button id="resettank" class="btn-wsevent btn btn-outline-primary ml-2">Tank zurücksetzen</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
@ -198,7 +195,7 @@
|
|||||||
<h4>Gerät neustarten</h4>
|
<h4>Gerät neustarten</h4>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col text-center">
|
<div class="col text-center">
|
||||||
<button id="reboot" class="btn-wsevent confirm btn btn-outline-primary">Reboot</button>
|
<button id="reboot" class="btn-wsevent btn btn-outline-primary">Reboot</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
@ -233,7 +230,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col text-center">
|
<div class="col text-center">
|
||||||
<button id="sourcesave" class="btn-wsevent confirm btn btn-outline-primary">Übernehmen</button>
|
<button id="sourcesave" class="btn-wsevent btn btn-outline-primary">Übernehmen</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
|
@ -4075,9 +4075,9 @@ input[type=submit].btn-block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.alert-success {
|
.alert-success {
|
||||||
color: #002200;
|
color: #012d36;
|
||||||
background-color: #99ff99;
|
background-color: #ccdde1;
|
||||||
border-color: #20bb20
|
border-color: #b8d0d5
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-success hr {
|
.alert-success hr {
|
||||||
@ -4089,9 +4089,9 @@ input[type=submit].btn-block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.alert-info {
|
.alert-info {
|
||||||
color: #000022;
|
color: #084367;
|
||||||
background-color: #99ddff;
|
background-color: #cfe6f4;
|
||||||
border-color: #2040FF
|
border-color: #bcdcef
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-info hr {
|
.alert-info hr {
|
||||||
@ -4103,9 +4103,9 @@ input[type=submit].btn-block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.alert-warning {
|
.alert-warning {
|
||||||
color: #222200;
|
color: #07767a;
|
||||||
background-color: #FFFF99;
|
background-color: #cff9fb;
|
||||||
border-color: #FFFF00
|
border-color: #bbf7f9
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-warning hr {
|
.alert-warning hr {
|
||||||
@ -4117,9 +4117,9 @@ input[type=submit].btn-block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.alert-danger {
|
.alert-danger {
|
||||||
color: #200000;
|
color: #851929;
|
||||||
background-color: #ffcccc;
|
background-color: #ffd6dc;
|
||||||
border-color: #AA2020
|
border-color: #ffc5ce
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-danger hr {
|
.alert-danger hr {
|
||||||
|
@ -75,16 +75,4 @@ hr {
|
|||||||
100% {
|
100% {
|
||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification-container {
|
|
||||||
position: fixed;
|
|
||||||
top: 30%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
z-index: 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.notification {
|
|
||||||
margin-bottom: 20px; /* Fügen Sie bei Bedarf weitere Stile hinzu */
|
|
||||||
}
|
|
@ -2,111 +2,142 @@ const jsonFilePath = "static/dtc_table.json";
|
|||||||
|
|
||||||
var dtcState = {};
|
var dtcState = {};
|
||||||
|
|
||||||
async function processDTCNotifications(dtcArray) {
|
function processDTCNotifications(dtcArray) {
|
||||||
if (dtcArray.length === 0 || dtcArray[0] == "0") {
|
|
||||||
dtcState = {};
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < dtcArray.length; i++) {
|
for (var i = 0; i < dtcArray.length; i++) {
|
||||||
var dtcInfo = dtcArray[i].split(",");
|
var dtcInfo = dtcArray[i].split(",");
|
||||||
var errorCode = parseInt(dtcInfo[1]);
|
var errorCode = dtcInfo[1];
|
||||||
var activity = parseInt(dtcInfo[3]);
|
var activity = parseInt(dtcInfo[3]);
|
||||||
var severity = parseInt(dtcInfo[2]);
|
|
||||||
|
|
||||||
try {
|
if (dtcState[errorCode]) {
|
||||||
var { title, description } = await getDescriptionForDTCNumber(errorCode);
|
// Überprüfen, ob sich der Zustand von "previous" auf "active" geändert hat
|
||||||
|
if (activity !== dtcState[errorCode]) {
|
||||||
switch (severity) {
|
|
||||||
case 1:
|
|
||||||
severity = "info";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
severity = "warning";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
severity = "danger";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dtcState[errorCode]) {
|
|
||||||
// Überprüfen, ob sich der Zustand von "previous" auf "active" geändert hat
|
|
||||||
if (activity !== dtcState[errorCode]) {
|
|
||||||
dtcState[errorCode] = activity;
|
|
||||||
if (activity === 1) showNotification(description, severity);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// DTC ist neu, Zustand speichern und Benachrichtigung anzeigen
|
|
||||||
dtcState[errorCode] = activity;
|
dtcState[errorCode] = activity;
|
||||||
showNotification(description, severity);
|
if (activity === 1) showDTCNotification(errorCode);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} else {
|
||||||
console.error("Error processing DTC:", error);
|
// DTC ist neu, Zustand speichern und Benachrichtigung anzeigen
|
||||||
|
dtcState[errorCode] = activity;
|
||||||
|
showDTCNotification(errorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDescriptionForDTCNumber(number) {
|
function showDTCNotification(dtctext, severity) {
|
||||||
return new Promise((resolve, reject) => {
|
// Überprüfen, ob der Browser die Notification API unterstützt
|
||||||
fetch(jsonFilePath)
|
if ("Notification" in window) {
|
||||||
.then((response) => response.json())
|
// Überprüfen, ob der Benutzer bereits Berechtigungen erteilt hat
|
||||||
.then((data) => {
|
if (Notification.permission === "granted") {
|
||||||
const dtcList = data.dtc_table_data;
|
// Benachrichtigung anzeigen
|
||||||
const foundEntry = dtcList.find((entry) => entry.num === number);
|
showNotification(dtctext, severity);
|
||||||
|
} else if (Notification.permission !== "denied") {
|
||||||
if (foundEntry) {
|
// Aufforderung zur Erlaubnis einholen
|
||||||
const description = foundEntry.description;
|
Notification.requestPermission().then(function (permission) {
|
||||||
const title = foundEntry.title;
|
if (permission === "granted") {
|
||||||
resolve({ title, description });
|
// Benachrichtigung anzeigen
|
||||||
|
showNotification(dtctext, severity);
|
||||||
} else {
|
} else {
|
||||||
// Wenn die Nummer nicht gefunden wurde, geben Sie einen Fehler zurück
|
// Der Benutzer hat die Berechtigung abgelehnt oder das Dialogfeld geschlossen
|
||||||
reject(`Beschreibung für Nummer ${number} nicht gefunden.`);
|
console.log("Benachrichtigungsberechtigung wurde verweigert.");
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
// Im Fehlerfall geben Sie den Fehler zurück
|
|
||||||
reject(error);
|
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
|
// Der Benutzer hat die Berechtigung bereits verweigert
|
||||||
|
console.log("Benachrichtigungsberechtigung wurde bereits verweigert.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showDTCModal(event) {
|
// Funktion zum Anzeigen der Benachrichtigung
|
||||||
|
function showNotification(dtctext, severity) {
|
||||||
|
var severityIcon;
|
||||||
|
switch (severity) {
|
||||||
|
case 1:
|
||||||
|
severityIcon = "static/img/info.png";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
severityIcon = "static/img/warn.png";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
severityIcon = "static/img/critical.png";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
severityIcon = "static/img/none.png";
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
body: dtctext,
|
||||||
|
icon: severityIcon,
|
||||||
|
};
|
||||||
|
|
||||||
|
var notification = new Notification("KTM Chain Oiler DTC", options);
|
||||||
|
|
||||||
|
// Optional: Handle Click-Event
|
||||||
|
notification.onclick = function () {
|
||||||
|
console.log("Benachrichtigung wurde angeklickt.");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDescriptionForDTCNumber(number, callback) {
|
||||||
|
fetch(jsonFilePath)
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((data) => {
|
||||||
|
const dtcList = data.dtc_table_data;
|
||||||
|
const foundEntry = dtcList.find((entry) => entry.num === number);
|
||||||
|
|
||||||
|
if (foundEntry) {
|
||||||
|
const description = foundEntry.description;
|
||||||
|
const title = foundEntry.title;
|
||||||
|
callback(null, title, description);
|
||||||
|
} else {
|
||||||
|
// Wenn die Nummer nicht gefunden wurde, geben Sie einen Fehler zurück
|
||||||
|
callback(
|
||||||
|
`Beschreibung für Nummer ${number} nicht gefunden.`,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
// Im Fehlerfall geben Sie den Fehler zurück
|
||||||
|
callback(error, null, null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showDTCModal(event) {
|
||||||
var dtc = parseInt(event.currentTarget.getAttribute("data-dtc"));
|
var dtc = parseInt(event.currentTarget.getAttribute("data-dtc"));
|
||||||
var debugval = event.currentTarget.getAttribute("data-debugval");
|
var debugval = event.currentTarget.getAttribute("data-debugval");
|
||||||
var modal = $("#dtcModal");
|
var modal = $("#dtcModal");
|
||||||
|
|
||||||
try {
|
getDescriptionForDTCNumber(dtc, function (error, title, description) {
|
||||||
var { title, description } = await getDescriptionForDTCNumber(dtc);
|
if (error) {
|
||||||
|
console.error("Fehler beim Abrufen der Beschreibung:", error);
|
||||||
modal.find(".modal-title").text(title);
|
modal.find(".modal-title").text("Fehler");
|
||||||
modal.find(".dtc-desc").text(description);
|
modal
|
||||||
|
.find(".dtc-desc")
|
||||||
if (debugval > 0) {
|
.text("DTC-Beschreibung konnte nicht geladen werden");
|
||||||
modal.find(".dtc-debugval").text("Debugvalue: " + debugval);
|
|
||||||
} else {
|
} else {
|
||||||
modal.find(".dtc-debugval").remove();
|
modal.find(".modal-title").text(title);
|
||||||
|
modal.find(".dtc-desc").text(description);
|
||||||
|
if (debugval > 0) {
|
||||||
|
modal.find(".dtc-debugval").text("Debugvalue: " + debugval);
|
||||||
|
} else {
|
||||||
|
modal.find(".dtc-debugval").remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
});
|
||||||
console.error("Fehler beim Abrufen der Beschreibung:", error);
|
|
||||||
modal.find(".modal-title").text("Fehler");
|
|
||||||
modal.find(".dtc-desc").text("DTC-Beschreibung konnte nicht geladen werden");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modal anzeigen
|
// Modal anzeigen
|
||||||
modal.modal("show");
|
modal.modal("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function fillDTCTable(dtcArray) {
|
function fillDTCTable(dtcArray) {
|
||||||
// Referenz auf das Tabellen-Element
|
// Referenz auf das Tabellen-Element
|
||||||
var table = document.getElementById("dtc_table");
|
var table = document.getElementById("dtc_table");
|
||||||
var tablediv = document.getElementById("dtc_container");
|
var tablediv = document.getElementById("dtc_container");
|
||||||
|
|
||||||
// Prüfen, ob DTC vorhanden sind
|
// Prüfen, ob DTC vorhanden sind
|
||||||
if (dtcArray.length === 0 || dtcArray[0] == "0") {
|
if (dtcArray.length === 0) {
|
||||||
// Verstecke das Tabellen-Div, wenn keine DTC vorhanden sind
|
// Verstecke das Tabellen-Div, wenn keine DTC vorhanden sind
|
||||||
tablediv.hidden = true;
|
tablediv.hidden = true;
|
||||||
table.innerHTML = "";
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Zeige das Tabellen-Div, wenn DTC vorhanden sind
|
// Zeige das Tabellen-Div, wenn DTC vorhanden sind
|
||||||
|
@ -25,7 +25,9 @@ function initButtons() {
|
|||||||
if (elements.length > 0) {
|
if (elements.length > 0) {
|
||||||
for (var i = 0; i < elements.length; i++) {
|
for (var i = 0; i < elements.length; i++) {
|
||||||
let element = elements[i];
|
let element = elements[i];
|
||||||
element.addEventListener("click", sendButton);
|
element.addEventListener("click", function () {
|
||||||
|
websocket_sendevent("btn-" + element.id, 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,58 +55,57 @@ function onClose(event) {
|
|||||||
overlay.style.display = "flex";
|
overlay.style.display = "flex";
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendButton(event) {
|
|
||||||
var targetElement = event.target;
|
|
||||||
|
|
||||||
if (
|
|
||||||
targetElement.classList.contains("confirm") &&
|
|
||||||
window.confirm("Sicher?") == false
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
|
|
||||||
websocket_sendevent("btn-" + targetElement.id, targetElement.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMessage(event) {
|
function onMessage(event) {
|
||||||
var data = event.data;
|
var data = event.data;
|
||||||
console.log("ws_msg:" + event.data + "\n");
|
console.log("ws_msg:" + event.data + "\n");
|
||||||
|
|
||||||
if (data.startsWith("NOTIFY:")) {
|
if (data.startsWith("DEBUG:")) {
|
||||||
var notify_data = data.slice(7).split(";")[1];
|
|
||||||
var notify_type = data.slice(7).split(";")[0];
|
|
||||||
showNotification(notify_data, notify_type);
|
|
||||||
} else if (data.startsWith("DEBUG:")) {
|
|
||||||
var addtext = data.slice(6);
|
var addtext = data.slice(6);
|
||||||
var livedebug_out = document.getElementById("livedebug-out");
|
var livedebug_out = document.getElementById("livedebug-out");
|
||||||
livedebug_out.value += addtext;
|
livedebug_out.value += addtext;
|
||||||
livedebug_out.scrollTop = livedebug_out.scrollHeight;
|
livedebug_out.scrollTop = livedebug_out.scrollHeight;
|
||||||
do_resize(livedebug_out);
|
do_resize(livedebug_out);
|
||||||
} else if (data.startsWith("DTC:")) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.startsWith("DTC:")) {
|
||||||
const dtcs = data.slice(4);
|
const dtcs = data.slice(4);
|
||||||
const dtcArray = dtcs.trim() !== "" ? dtcs.split(";").filter(Boolean) : [];
|
const dtcArray = dtcs.trim() !== "" ? dtcs.split(";").filter(Boolean) : [];
|
||||||
|
|
||||||
processDTCNotifications(dtcArray);
|
if (dtcArray[0] != "0") {
|
||||||
fillDTCTable(dtcArray);
|
processDTCNotifications(dtcArray);
|
||||||
|
fillDTCTable(dtcArray);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (data.startsWith("MAPPING_STATUS:")) {
|
if (data.startsWith("MAPPING_STATUS:")) {
|
||||||
const data_sliced = data.slice(15);
|
const data_sliced = data.slice(15);
|
||||||
statusMapping = createMapping(data_sliced);
|
statusMapping = createMapping(data_sliced);
|
||||||
} else if (data.startsWith("MAPPING_STATIC:")) {
|
}
|
||||||
|
|
||||||
|
if (data.startsWith("MAPPING_STATIC:")) {
|
||||||
const data_sliced = data.slice(15);
|
const data_sliced = data.slice(15);
|
||||||
staticMapping = createMapping(data_sliced);
|
staticMapping = createMapping(data_sliced);
|
||||||
} else if (data.startsWith("STATUS:")) {
|
}
|
||||||
|
|
||||||
|
if (data.startsWith("STATUS:")) {
|
||||||
const data_sliced = data.slice(7);
|
const data_sliced = data.slice(7);
|
||||||
const result = processDataString(data_sliced, statusMapping);
|
const result = processDataString(data_sliced, statusMapping);
|
||||||
console.log("STATUS:");
|
console.log("STATUS:");
|
||||||
console.log(JSON.stringify(result, null, 2));
|
console.log(JSON.stringify(result, null, 2));
|
||||||
fillValuesToHTML(result);
|
fillValuesToHTML(result);
|
||||||
} else if (data.startsWith("STATIC:")) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.startsWith("STATIC:")) {
|
||||||
const data_sliced = data.slice(7);
|
const data_sliced = data.slice(7);
|
||||||
const result = processDataString(data_sliced, staticMapping);
|
const result = processDataString(data_sliced, staticMapping);
|
||||||
console.log("STATIC:");
|
console.log("STATIC:");
|
||||||
console.log(JSON.stringify(result, null, 2));
|
console.log(JSON.stringify(result, null, 2));
|
||||||
fillValuesToHTML(result);
|
fillValuesToHTML(result);
|
||||||
overlay.style.display = "none";
|
overlay.style.display = "none";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,27 +211,3 @@ function updateProgressBar(progressBar, value) {
|
|||||||
progressBar.style.width = value + "%";
|
progressBar.style.width = value + "%";
|
||||||
progressBar.textContent = value + "%";
|
progressBar.textContent = value + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNotification(message, type) {
|
|
||||||
// Erstellen Sie ein Bootstrap-Alert-Element
|
|
||||||
var alertElement = $(
|
|
||||||
'<div class="alert alert-' +
|
|
||||||
type +
|
|
||||||
' alert-dismissible fade show notification" role="alert">' +
|
|
||||||
"<strong>" +
|
|
||||||
message +
|
|
||||||
"</strong>" +
|
|
||||||
'<button type="button" class="close" data-dismiss="alert" aria-label="Close">' +
|
|
||||||
'<span aria-hidden="true">×</span>' +
|
|
||||||
"</button>" +
|
|
||||||
"</div>"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Fügen Sie das Alert-Element dem Container hinzu
|
|
||||||
$("#notification-container").append(alertElement);
|
|
||||||
|
|
||||||
// Nach 5 Sekunden das Alert-Element ausblenden
|
|
||||||
setTimeout(function () {
|
|
||||||
alertElement.alert("close");
|
|
||||||
}, 5000);
|
|
||||||
}
|
|
||||||
|
@ -31,19 +31,10 @@
|
|||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#include "struct2json.h"
|
#include "struct2json.h"
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
info,
|
|
||||||
success,
|
|
||||||
warning,
|
|
||||||
error
|
|
||||||
} NotificationType_t;
|
|
||||||
|
|
||||||
void initWebUI();
|
void initWebUI();
|
||||||
void Webserver_Process();
|
void Webserver_Process();
|
||||||
void Webserver_Shutdown();
|
void Webserver_Shutdown();
|
||||||
|
|
||||||
void Websocket_PushLiveDebug(String Message);
|
void Websocket_PushLiveDebug(String Message);
|
||||||
void Websocket_PushNotification(String Message, NotificationType_t type);
|
|
||||||
|
|
||||||
#endif // _WEBUI_H_
|
#endif // _WEBUI_H_
|
||||||
|
@ -73,7 +73,6 @@ void Debug_Process()
|
|||||||
inputBuffer[inputCnt] = 0; // terminate the String
|
inputBuffer[inputCnt] = 0; // terminate the String
|
||||||
inputCnt = 0;
|
inputCnt = 0;
|
||||||
InputProcessed = CMD_COMPLETE;
|
InputProcessed = CMD_COMPLETE;
|
||||||
Serial.write(inputChar);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x1B: // Esc
|
case 0x1B: // Esc
|
||||||
@ -85,7 +84,6 @@ void Debug_Process()
|
|||||||
case 0x21 ... 0x7E: // it's a real letter or sign and not some control-chars
|
case 0x21 ... 0x7E: // it's a real letter or sign and not some control-chars
|
||||||
inputBuffer[inputCnt] = inputChar;
|
inputBuffer[inputCnt] = inputChar;
|
||||||
inputCnt++;
|
inputCnt++;
|
||||||
Serial.write(inputChar);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -119,10 +117,6 @@ void Debug_Process()
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InputProcessed != IDLE)
|
|
||||||
Serial.print(">");
|
|
||||||
|
|
||||||
InputProcessed = IDLE;
|
InputProcessed = IDLE;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -158,7 +152,7 @@ void Debug_pushMessage(const char *format, ...)
|
|||||||
if ((DebuggerStatus[dbg_Serial] == enabled) || (DebuggerStatus[dbg_Webui] == enabled))
|
if ((DebuggerStatus[dbg_Serial] == enabled) || (DebuggerStatus[dbg_Webui] == enabled))
|
||||||
{
|
{
|
||||||
char buff[128]; // Buffer to hold the formatted message
|
char buff[128]; // Buffer to hold the formatted message
|
||||||
va_list arg; // Variable argument list for vsnprintf
|
va_list arg; // Variable argument list for vsnprintf
|
||||||
va_start(arg, format);
|
va_start(arg, format);
|
||||||
|
|
||||||
// Format the message and store it in the buffer
|
// Format the message and store it in the buffer
|
||||||
@ -263,14 +257,6 @@ void processCmdDebug(String command)
|
|||||||
MaintainDTC(DTC_FAKE_DTC_WARN, true, millis());
|
MaintainDTC(DTC_FAKE_DTC_WARN, true, millis());
|
||||||
else if (command == "dtc_info")
|
else if (command == "dtc_info")
|
||||||
MaintainDTC(DTC_FAKE_DTC_INFO, true, millis());
|
MaintainDTC(DTC_FAKE_DTC_INFO, true, millis());
|
||||||
else if (command == "notify_error")
|
|
||||||
Websocket_PushNotification("Debug Error Notification", error);
|
|
||||||
else if (command == "notify_warning")
|
|
||||||
Websocket_PushNotification("Debug Warning Notification", warning);
|
|
||||||
else if (command == "notify_success")
|
|
||||||
Websocket_PushNotification("Debug Success Notification", success);
|
|
||||||
else if (command == "notify_info")
|
|
||||||
Websocket_PushNotification("Debug Info Notification", info);
|
|
||||||
else
|
else
|
||||||
Debug_pushMessage("unknown Command\n");
|
Debug_pushMessage("unknown Command\n");
|
||||||
}
|
}
|
||||||
|
@ -492,10 +492,6 @@ void Websocket_HandleButtons(uint8_t *data)
|
|||||||
{
|
{
|
||||||
globals.systemStatus = sysStat_Shutdown;
|
globals.systemStatus = sysStat_Shutdown;
|
||||||
}
|
}
|
||||||
else if (strcmp(identifier, "resettank") == 0)
|
|
||||||
{
|
|
||||||
PersistenceData.tankRemain_microL = LubeConfig.tankCapacity_ml * 1000;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug_pushMessage("Got unknown Button-id '%s' from ws-client\n", identifier);
|
Debug_pushMessage("Got unknown Button-id '%s' from ws-client\n", identifier);
|
||||||
@ -536,38 +532,6 @@ void Websocket_HandleSettings(uint8_t *data)
|
|||||||
int index = findIndexByString(value, GPSBaudRateString, GPSBaudRateString_Elements);
|
int index = findIndexByString(value, GPSBaudRateString, GPSBaudRateString_Elements);
|
||||||
LubeConfig.GPSBaudRate = (GPSBaudRate_t)index;
|
LubeConfig.GPSBaudRate = (GPSBaudRate_t)index;
|
||||||
}
|
}
|
||||||
else if (strcmp(identifier, "ledmaxbrightness") == 0)
|
|
||||||
{
|
|
||||||
LubeConfig.LED_Max_Brightness = atoi(value);
|
|
||||||
}
|
|
||||||
else if (strcmp(identifier, "ledminbrightness") == 0)
|
|
||||||
{
|
|
||||||
LubeConfig.LED_Min_Brightness = atoi(value);
|
|
||||||
}
|
|
||||||
else if (strcmp(identifier, "pumppulse") == 0)
|
|
||||||
{
|
|
||||||
LubeConfig.BleedingPulses = atoi(value);
|
|
||||||
}
|
|
||||||
else if (strcmp(identifier, "tankwarn") == 0)
|
|
||||||
{
|
|
||||||
LubeConfig.TankRemindAtPercentage = atoi(value);
|
|
||||||
}
|
|
||||||
else if (strcmp(identifier, "tankcap") == 0)
|
|
||||||
{
|
|
||||||
LubeConfig.tankCapacity_ml = atoi(value);
|
|
||||||
}
|
|
||||||
else if (strcmp(identifier, "lubedistancerain") == 0)
|
|
||||||
{
|
|
||||||
LubeConfig.DistancePerLube_Rain = atoi(value);
|
|
||||||
}
|
|
||||||
else if (strcmp(identifier, "lubedistancenormal") == 0)
|
|
||||||
{
|
|
||||||
LubeConfig.DistancePerLube_Default = atoi(value);
|
|
||||||
}
|
|
||||||
else if (strcmp(identifier, "ledmodeflash") == 0)
|
|
||||||
{
|
|
||||||
LubeConfig.LED_Mode_Flash = value[0] == '1' ? true : false;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug_pushMessage("Got unknown Settings-id and value '%s' from ws-client\n", identifier);
|
Debug_pushMessage("Got unknown Settings-id and value '%s' from ws-client\n", identifier);
|
||||||
@ -830,38 +794,4 @@ int findIndexByString(const char *searchString, const char *const *array, int ar
|
|||||||
}
|
}
|
||||||
// String nicht gefunden, gib -1 zurück
|
// String nicht gefunden, gib -1 zurück
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Pushes a notification to all WebSocket clients.
|
|
||||||
*
|
|
||||||
* This function sends a live debug message to all connected WebSocket clients.
|
|
||||||
*
|
|
||||||
* @param Message The debug message to be sent.
|
|
||||||
* @param type The type of notification (info, success, warning, error).
|
|
||||||
* - Use NotificationType_t::info for informational messages.
|
|
||||||
* - Use NotificationType_t::success for successful operation messages.
|
|
||||||
* - Use NotificationType_t::warning for warning messages.
|
|
||||||
* - Use NotificationType_t::error for error messages.
|
|
||||||
*/
|
|
||||||
void Websocket_PushNotification(String Message, NotificationType_t type)
|
|
||||||
{
|
|
||||||
String typeString = "";
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case info:
|
|
||||||
typeString = "info";
|
|
||||||
break;
|
|
||||||
case success:
|
|
||||||
typeString = "success";
|
|
||||||
break;
|
|
||||||
case warning:
|
|
||||||
typeString = "warning";
|
|
||||||
break;
|
|
||||||
case error:
|
|
||||||
typeString = "danger";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
webSocket.textAll("NOTIFY:" + typeString + ";" + Message);
|
|
||||||
Debug_pushMessage("Sending Notification to WebUI: %s\n", typeString);
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user