From 3a23dae178e9ce1a0436dfb32388c4da11d75ed2 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 26 Feb 2024 14:57:59 +0100 Subject: [PATCH] show in info and use for mqtt: heap_caps_get_free_size, #1622 --- src/mqtt.cpp | 3 ++- src/system.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 157f5109e..bb9d487fb 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -607,7 +607,8 @@ bool Mqtt::queue_message(const uint8_t operation, const std::string & topic, con } // check free mem #ifndef EMSESP_STANDALONE - if (ESP.getFreeHeap() < 60 * 1024 || ESP.getMaxAllocHeap() < 40 * 1024) { + // if (ESP.getFreeHeap() < 60 * 1024 || ESP.getMaxAllocHeap() < 40 * 1024) { + if (heap_caps_get_free_size(MALLOC_CAP_8BIT) < 60 * 1024) { // checks free Heap+PSRAM if (operation == Operation::PUBLISH) { mqtt_message_id_++; mqtt_publish_fails_++; diff --git a/src/system.cpp b/src/system.cpp index 026277491..8040b6c85 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -1209,6 +1209,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output node["sdk"] = ESP.getSdkVersion(); node["free mem"] = getHeapMem(); node["max alloc"] = getMaxAllocMem(); + node["free caps"] = heap_caps_get_free_size(MALLOC_CAP_8BIT) / 1024; // includes heap and psram node["used app"] = EMSESP::system_.appUsed(); // kilobytes node["free app"] = EMSESP::system_.appFree(); // kilobytes node["partition"] = esp_ota_get_running_partition()->label;