diff --git a/Software/src/webui.cpp b/Software/src/webui.cpp index bdcdcc2..2553a9c 100644 --- a/Software/src/webui.cpp +++ b/Software/src/webui.cpp @@ -594,44 +594,45 @@ void Websocket_RefreshClientData_DTCs(uint32_t client_id) */ 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) - { - const char mapping[] = "MAPPING_STATUS:" - "batterylevel;" - "systemstatus;" - "activefaction;" - "time_faction1;" - "time_faction2;" - "time_faction3;"; + if (client_id > 0) + webSocket.text(client_id, mapping); + else + webSocket.textAll(mapping); + + Debug_pushMessage("send MAPPING_STATUS WS-Client Data\n"); + } + + 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) - webSocket.text(client_id, mapping); + { + webSocket.text(client_id, dataString); + } else - webSocket.textAll(mapping); - - 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); - } + { + webSocket.textAll(dataString); + } } + /** * @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) { + Debug_pushMessage("send STATIC WS-Client Data\n"); if (send_mapping) { 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); else webSocket.textAll(mapping); + + Debug_pushMessage("send MAPPING_STATIC WS-Client Data\n"); } char dataString[200]; // Maximal 200 Zeichen für den Data-String