some buttons are now websocket-handled
This commit is contained in:
parent
6a9d09ddf3
commit
286ba1fe6c
@ -225,8 +225,8 @@
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col text-center">
|
||||
<button id="btn-ws-start" class="btn btn-outline-primary">Start</button>
|
||||
<button id="btn-ws-stop" class="btn btn-outline-primary ml-2">Stop</button>
|
||||
<button id="btn-debugstart" class="btn-wsevent btn btn-outline-primary ml-2">Start</button>
|
||||
<button id="btn-debugstop" class="btn-wsevent btn btn-outline-primary ml-2">Stop</button>
|
||||
</div>
|
||||
</div>
|
||||
</p>
|
||||
@ -235,13 +235,11 @@
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Gerät neustarten</h4>
|
||||
<form action="post.htm" method="POST" class="form-horizontal">
|
||||
<div class="form-group row">
|
||||
<div class="col text-center">
|
||||
<button name="reboot" type="submit" class="btn btn-outline-primary">Reboot</button>
|
||||
<button id="btn-reboot" class="btn-wsevent btn btn-outline-primary">Reboot</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
<!-- Div Group Device Reboot -->
|
||||
</div>
|
||||
|
@ -15,12 +15,31 @@ function initWebSocket() {
|
||||
}
|
||||
|
||||
function initButtons() {
|
||||
document
|
||||
.getElementById("btn-ws-stop")
|
||||
.addEventListener("click", livedebug_stop);
|
||||
document
|
||||
.getElementById("btn-ws-start")
|
||||
.addEventListener("click", livedebug_start);
|
||||
|
||||
var elements = document.getElementsByClassName("btn-wsevent");
|
||||
|
||||
if (elements.length > 0) {
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
var element = elements[i];
|
||||
element.addEventListener("click", function () {
|
||||
websocket_sendevent("btn-" + element.id, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initSettingInputs() {
|
||||
|
||||
var elements = document.getElementsByClassName("btn-wssetting");
|
||||
|
||||
if (elements.length > 0) {
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
var element = elements[i];
|
||||
element.addEventListener("change", function () {
|
||||
websocket_sendevent("set-" + element.id, element.value);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onOpen(event) {
|
||||
@ -112,14 +131,11 @@ function processDataString(dataString, mapping) {
|
||||
function onLoad(event) {
|
||||
initWebSocket();
|
||||
initButtons();
|
||||
initSettingInputs();
|
||||
}
|
||||
|
||||
function livedebug_start() {
|
||||
websocket.send("start");
|
||||
}
|
||||
|
||||
function livedebug_stop() {
|
||||
websocket.send("stop");
|
||||
function websocket_sendevent(element_id, element_value) {
|
||||
websocket.send(element_id + ":" + element_value);
|
||||
}
|
||||
|
||||
function do_resize(textbox) {
|
||||
|
@ -32,6 +32,8 @@ void Websocket_HandleMessage(void *arg, uint8_t *data, size_t len);
|
||||
void Websocket_RefreshClientData_DTCs(uint32_t client_id);
|
||||
void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping = false);
|
||||
void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping = false);
|
||||
void Websocket_HandleButtons(uint8_t *data);
|
||||
void Websocket_HandleSettings(uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Initializes the web-based user interface (WebUI) for the ChainLube application.
|
||||
@ -180,8 +182,6 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
|
||||
globals.requestEEAction = EE_CFG_SAVE;
|
||||
// end: POST Form Oiltank
|
||||
// begin: POST Form Maintenance
|
||||
if (p->name() == "purgepulse")
|
||||
LubeConfig.BleedingPulses = p->value().toInt();
|
||||
if (p->name() == "maintsave")
|
||||
globals.requestEEAction = EE_CFG_SAVE;
|
||||
if (p->name() == "resettank")
|
||||
@ -204,15 +204,6 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
|
||||
globals.requestEEAction = globals.requestEEAction == EE_PDS_FORMAT ? EE_FORMAT_ALL : EE_CFG_FORMAT;
|
||||
}
|
||||
}
|
||||
if (p->name() == "purgenow")
|
||||
{
|
||||
globals.systemStatus = sysStat_Purge;
|
||||
globals.purgePulses = LubeConfig.BleedingPulses;
|
||||
}
|
||||
if (p->name() == "reboot")
|
||||
{
|
||||
globals.systemStatus = sysStat_Shutdown;
|
||||
}
|
||||
// end: POST Form Maintenance
|
||||
// begin: POST Form LED Settings
|
||||
if (p->name() == "ledmaxbrightness")
|
||||
@ -234,12 +225,6 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
|
||||
globals.requestEEAction = EE_CFG_SAVE;
|
||||
}
|
||||
// end: POST Form LED SEttings
|
||||
// begin: POST Form Measure Pulses
|
||||
if (p->name() == "measurereset")
|
||||
globals.measuredPulses = 0;
|
||||
if (p->name() == "measurestartstop")
|
||||
globals.measurementActive = !globals.measurementActive;
|
||||
// end: POST Form Measure Pulses
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,21 +515,57 @@ void Websocket_HandleMessage(void *arg, uint8_t *data, size_t len)
|
||||
{
|
||||
data[len] = 0;
|
||||
|
||||
Debug_pushMessage("Got WebSocket Message: %s \n", (char *)data);
|
||||
if (strncmp((char *)data, "btn-", strlen("btn-")) == 0)
|
||||
{
|
||||
Websocket_HandleButtons(data + strlen("btn-"));
|
||||
}
|
||||
if (strncmp((char *)data, "set-", strlen("set-")) == 0)
|
||||
{
|
||||
Websocket_HandleSettings(data + strlen("set-"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug_pushMessage("Got unknown Websocket-Message '%s' from client\n", (char *)data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp((char *)data, "start") == 0)
|
||||
void Websocket_HandleButtons(uint8_t *data)
|
||||
{
|
||||
if (strcmp((char *)data, "debugstart") == 0)
|
||||
{
|
||||
SetDebugportStatus(dbg_Webui, enabled);
|
||||
}
|
||||
else if (strcmp((char *)data, "stop") == 0)
|
||||
else if (strcmp((char *)data, "debugstop") == 0)
|
||||
{
|
||||
SetDebugportStatus(dbg_Webui, disabled);
|
||||
}
|
||||
else if (strcmp((char *)data, "foo") == 0)
|
||||
else if (strcmp((char *)data, "measurereset") == 0)
|
||||
{
|
||||
Debug_pushMessage("Got WebSocket Message 'foo' from client\n");
|
||||
globals.measuredPulses = 0;
|
||||
}
|
||||
else if (strcmp((char *)data, "measurestartstop") == 0)
|
||||
{
|
||||
globals.measurementActive = !globals.measurementActive;
|
||||
}
|
||||
else if (strcmp((char *)data, "purgenow") == 0)
|
||||
{
|
||||
globals.systemStatus = sysStat_Purge;
|
||||
globals.purgePulses = LubeConfig.BleedingPulses;
|
||||
}
|
||||
else if (strcmp((char *)data, "reboot") == 0)
|
||||
{
|
||||
globals.systemStatus = sysStat_Shutdown;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug_pushMessage("Got unknown Button-id '%s' from ws-client\n", (char *)data);
|
||||
}
|
||||
}
|
||||
|
||||
void Websocket_HandleSettings(uint8_t *data)
|
||||
{
|
||||
Debug_pushMessage("Got Settings-id and value '%s' from ws-client\n", (char *)data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user