diff --git a/html/format.htm b/html/format.htm index 22a3731..3776f66 100644 --- a/html/format.htm +++ b/html/format.htm @@ -64,6 +64,11 @@ + +
@@ -117,7 +129,7 @@
-
@@ -158,6 +170,9 @@
+
+
+
 
@@ -171,6 +186,8 @@
   
 
diff --git a/html/format.min.htm b/html/format.min.htm
index 306ebb5..0be9b83 100644
--- a/html/format.min.htm
+++ b/html/format.min.htm
@@ -1,4 +1,4 @@
-Beer Gravity Monitor


(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file + { "id": "UBIDots-Post", "format": "%7B%0A%20%20%20%22temperature%22%3A%20%24%7Btemp%7D%2C%0A%20%20%20%22gravity%22%3A%20%24%7Bgravity%7D%2C%0A%20%20%20%22angle%22%3A%20%24%7Bangle%7D%2C%0A%20%20%20%22battery%22%3A%20%24%7Bbattery%7D%2C%0A%20%20%20%22rssi%22%3A%20%24%7Brssi%7D%0A%7D" } ];

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/src/helper.cpp b/src/helper.cpp index 9f15da5..b999ed4 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -63,7 +63,7 @@ void writeErrorLog(const char* format, ...) { char buf[80]; vsnprintf(&buf[0], sizeof(buf), format, arg); f.write(&buf[0], strlen(&buf[0])); - Log.error(&buf[0]); + Log.errorln(&buf[0]); va_end(arg); f.println(); f.close(); diff --git a/src/pushtarget.cpp b/src/pushtarget.cpp index aad8a8d..f6a32fd 100644 --- a/src/pushtarget.cpp +++ b/src/pushtarget.cpp @@ -141,6 +141,7 @@ void PushTarget::sendAll(float angle, float gravitySG, float corrGravitySG, LOG_PERF_STOP("push-mqtt"); } + engine.freeMemory(); intDelay.save(); } diff --git a/src/templating.hpp b/src/templating.hpp index 5a1ff8e..3935312 100644 --- a/src/templating.hpp +++ b/src/templating.hpp @@ -131,6 +131,7 @@ class TemplatingEngine { } } + freeMemory(); // In case this is reused _output = static_cast(malloc(size + 20)); if (!_output) { @@ -159,7 +160,15 @@ class TemplatingEngine { } } } - strncat(_output, format + k, strlen(format + k)); + strncat(_output, format + k, size - k); + Log.notice(F("TPL : Transformed template %d chars to %d chars" CR), + strlen(format), strlen(_output)); + +#if LOG_LEVEL == 6 + printHeap("TPL "); + Log.verboseln(format); + Log.verboseln(_output); +#endif } void dumpAll() { @@ -187,7 +196,9 @@ class TemplatingEngine { void freeMemory() { if (_output) free(_output); + _output = 0; + _baseTemplate.clear(); } void initialize(float angle, float gravitySG, float corrGravitySG, float tempC, float runTime); diff --git a/src/webserver.cpp b/src/webserver.cpp index 78dc4e6..7ac8bc0 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -949,6 +949,7 @@ void WebServerHandler::webHandleTestPush() { enabled = true; } + engine.freeMemory(); DynamicJsonDocument doc(100); doc[PARAM_PUSH_ENABLED] = enabled; doc[PARAM_PUSH_SUCCESS] = push.getLastSuccess();