improvement of webui-function

This commit is contained in:
Marcel Peterkau 2024-06-02 23:37:04 +02:00
parent 73c486be73
commit 48774a42f4

View File

@ -594,44 +594,45 @@ void Websocket_RefreshClientData_DTCs(uint32_t client_id)
*/ */
void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping) void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping)
{ {
if (send_mapping)
{
const char mapping[] = "MAPPING_STATUS:"
"batterylevel;"
"systemstatus;"
"activefaction;"
"time_faction1;"
"time_faction2;"
"time_faction3;";
if (send_mapping) if (client_id > 0)
{ webSocket.text(client_id, mapping);
const char mapping[] = "MAPPING_STATUS:" else
"batterylevel;" webSocket.textAll(mapping);
"systemstatus;"
"activefaction;" Debug_pushMessage("send MAPPING_STATUS WS-Client Data\n");
"time_faction1;" }
"time_faction2;"
"time_faction3;"; char dataString[200] = {0}; // Maximal 200 Zeichen für den Data-String
sprintf(dataString, "STATUS:%d;%s;%d;%ld;%ld;%ld;",
globals.battery_level,
globals.systemStatustxt,
PersistenceData.activeFaction,
PersistenceData.faction_1_timer,
PersistenceData.faction_2_timer,
PersistenceData.faction_3_timer);
if (client_id > 0) if (client_id > 0)
webSocket.text(client_id, mapping); {
webSocket.text(client_id, dataString);
}
else else
webSocket.textAll(mapping); {
webSocket.textAll(dataString);
Debug_pushMessage("send MAPPING_STATUS WS-Client Data\n"); }
}
String temp = "STATUS:";
temp.concat(String(globals.battery_level) + ";");
temp.concat(String(globals.systemStatustxt) + ";");
temp.concat(String(PersistenceData.activeFaction) + ";");
temp.concat(String(PersistenceData.faction_1_timer) + ";");
temp.concat(String(PersistenceData.faction_2_timer) + ";");
temp.concat(String(PersistenceData.faction_3_timer) + ";");
if (client_id > 0)
{
webSocket.text(client_id, temp);
}
else
{
webSocket.textAll(temp);
}
} }
/** /**
* @brief Refreshes client data related to static configuration parameters on WebSocket clients. * @brief Refreshes client data related to static configuration parameters on WebSocket clients.
* *
@ -645,6 +646,7 @@ void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping)
void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping) void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping)
{ {
Debug_pushMessage("send STATIC WS-Client Data\n");
if (send_mapping) if (send_mapping)
{ {
const char mapping[] = "MAPPING_STATIC:" const char mapping[] = "MAPPING_STATIC:"
@ -664,6 +666,8 @@ void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping)
webSocket.text(client_id, mapping); webSocket.text(client_id, mapping);
else else
webSocket.textAll(mapping); webSocket.textAll(mapping);
Debug_pushMessage("send MAPPING_STATIC WS-Client Data\n");
} }
char dataString[200]; // Maximal 200 Zeichen für den Data-String char dataString[200]; // Maximal 200 Zeichen für den Data-String