diff --git a/src/main.cpp b/src/main.cpp index 958fecc..b823b19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -271,7 +271,6 @@ void loopGravityOnInterval() { LOG_PERF_STOP("loop-gyro-read"); myBatteryVoltage.read(); checkSleepMode(myGyro.getAngle(), myBatteryVoltage.getVoltage()); - LOG_PERF_PUSH(); } } diff --git a/src/pushtarget.cpp b/src/pushtarget.cpp index 3d3525f..85959ce 100644 --- a/src/pushtarget.cpp +++ b/src/pushtarget.cpp @@ -23,6 +23,8 @@ SOFTWARE. */ #if defined (ESP8266) #include +#include +#include #else // defined (ESP32) #include #endif @@ -45,14 +47,22 @@ void PushTarget::send(float angle, float gravitySG, float corrGravitySG, if ((timePassed < interval) && !force) { #if LOG_LEVEL == 6 && !defined(PUSH_DISABLE_LOGGING) -/* Log.verbose(F("PUSH: Timer has not expired %l vs %l." CR), timePassed, - interval);*/ + Log.verbose(F("PUSH: Timer has not expired %l vs %l." CR), timePassed, + interval); #endif return; } _ms = millis(); + if (ESP.getFreeContStack() < 1500) { + Log.error(F("PUSH: Low on memory, skipping push since it will crasch. (stack=%d, heap=%d)." CR), ESP.getFreeContStack(), ESP.getFreeHeap()); + myWifi.closeWifiClient(); + return; + } + + //MDNS.close(); + TemplatingEngine engine; engine.initialize(angle, gravitySG, corrGravitySG, tempC, runTime); @@ -85,6 +95,8 @@ void PushTarget::send(float angle, float gravitySG, float corrGravitySG, sendMqtt(engine); LOG_PERF_STOP("push-mqtt"); } + + LOG_PERF_PUSH(); } // diff --git a/test/configure.py b/test/configure.py index 23eaf09..c9deb7f 100644 --- a/test/configure.py +++ b/test/configure.py @@ -36,7 +36,11 @@ json = { "id": id, "influxdb2-push": "", # InfluxDB2 settings "influxdb2-org": "", "influxdb2-bucket": "", - "influxdb2-auth": "" + "influxdb2-auth": "" , + "mqtt-push": "", + "mqtt-port": 1883, + "mqtt-user": "", + "mqtt-pass": "" } set_config( url, json )