From a49a4b2d4519d75f076072bc19658355a04885df Mon Sep 17 00:00:00 2001 From: IgorYbema Date: Mon, 2 Sep 2024 20:45:43 +0200 Subject: [PATCH] fix stupid mistake on limiting data per webloop --- HeishaMon/webfunctions.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/HeishaMon/webfunctions.cpp b/HeishaMon/webfunctions.cpp index e682d85d..0ccb67b2 100755 --- a/HeishaMon/webfunctions.cpp +++ b/HeishaMon/webfunctions.cpp @@ -1131,7 +1131,8 @@ int handleJsonOutput(struct webserver_t *client, char* actData, char* actDataExt webserver_send(client, 200, (char *)"application/json", 0); webserver_send_content_P(client, PSTR("{\"heatpump\":["), 13); } else if ((client->content - 1) < NUMBER_OF_TOPICS) { - for (uint8_t topic = client->content - 1; topic < NUMBER_OF_TOPICS && topic < client->content ; topic++) { //1 TOP per webserver run (because content was 1 at start, so makes 5) + uint8_t maxTopics = client->content + 4; //limit the amount of topic sent per webloop + for (uint8_t topic = client->content - 1; topic < NUMBER_OF_TOPICS && topic < maxTopics ; topic++) { webserver_send_content_P(client, PSTR("{\"Topic\":\"TOP"), 13); @@ -1188,7 +1189,8 @@ int handleJsonOutput(struct webserver_t *client, char* actData, char* actDataExt if (client->content == NUMBER_OF_TOPICS + 1) { webserver_send_content_P(client, PSTR("],\"heatpump extra\":["), 20); } - for (uint8_t topic = (client->content - NUMBER_OF_TOPICS - 1); topic < extraTopics && topic < (client->content - NUMBER_OF_TOPICS + 4) ; topic++) { + uint8_t maxTopics = client->content - NUMBER_OF_TOPICS + 4; //limit the amount of topic sent per webloop + for (uint8_t topic = (client->content - NUMBER_OF_TOPICS - 1); topic < extraTopics && topic < maxTopics ; topic++) { webserver_send_content_P(client, PSTR("{\"Topic\":\"XTOP"), 14);