From 11f3ff96e49f9b62f5cca0b2c9959955200e9149 Mon Sep 17 00:00:00 2001
From: eadmaster <925171+eadmaster@users.noreply.github.com>
Date: Wed, 7 Aug 2024 00:06:34 +0200
Subject: [PATCH] added webui serial button (#107)
---
src/modules/others/webInterface.cpp | 5 +++--
src/modules/others/webInterface.h | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/modules/others/webInterface.cpp b/src/modules/others/webInterface.cpp
index 0b35b539..42ad3ec7 100644
--- a/src/modules/others/webInterface.cpp
+++ b/src/modules/others/webInterface.cpp
@@ -307,9 +307,10 @@ void configureWebServer() {
if (server->hasArg("cmnd")) {
String cmnd = server->arg("cmnd");
if( processSerialCommand( cmnd ) ) {
- server->send(200, "text/plain", "OK");
+ setup_gpio(); // temp fix for menu inf. loop
+ server->send(200, "text/plain", "command " + cmnd + " success");
} else {
- server->send(400, "text/plain", "ERROR, check the serial log on the device for details");
+ server->send(400, "text/plain", "command failed, check the serial log for details");
}
}
server->send(400, "text/plain", "http request missing required arg: cmnd");
diff --git a/src/modules/others/webInterface.h b/src/modules/others/webInterface.h
index be662ca6..8c668b18 100644
--- a/src/modules/others/webInterface.h
+++ b/src/modules/others/webInterface.h
@@ -331,6 +331,7 @@ const char index_html[] PROGMEM = R"rawliteral(
+
@@ -362,6 +363,21 @@ function WifiConfig() {
}
}
+function serialCmd() {
+ let cmd = prompt("Enter a serial command", "");
+ if (cmd == null || cmd == "" || cmd == null) {
+ window.alert("empty command, nothing sent");
+ } else {
+ const ajax5 = new XMLHttpRequest();
+ const formdata5 = new FormData();
+ formdata5.append("cmnd", cmd);
+ ajax5.open("POST", "/cm", false);
+ ajax5.send(formdata5);
+ //document.getElementById("status").innerHTML = ajax5.responseText;
+ window.alert(ajax5.responseText);
+ }
+}
+
function logoutButton() {
var xhr = new XMLHttpRequest();
xhr.open("GET", "/logout", true);