diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 0fa0370d6..69415e194 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -154,9 +154,7 @@ void ExecuteCommand(const char *cmnd, uint32_t source) // cmnd: "status 0" = stopic "status" and svalue " 0" // cmnd: "var1 =1" = stopic "var1" and svalue " =1" // cmnd: "var1=1" = stopic "var1" and svalue "=1" -#ifdef USE_DEBUG_DRIVER - ShowFreeMem(PSTR("ExecuteCommand")); -#endif + SHOW_FREE_MEM(PSTR("ExecuteCommand")); ShowSource(source); const char *pos = cmnd; @@ -196,9 +194,7 @@ void ExecuteCommand(const char *cmnd, uint32_t source) void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) { -#ifdef USE_DEBUG_DRIVER - ShowFreeMem(PSTR("CommandHandler")); -#endif + SHOW_FREE_MEM(PSTR("CommandHandler")); bool grpflg = false; uint32_t real_index = SET_MQTT_GRP_TOPIC; diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index b481325b5..fe34a5942 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -502,6 +502,11 @@ bool first_device_group_is_local = true; #define DEBUG_TRACE_LOG(...) #endif +#ifdef USE_DEBUG_DRIVER +#define SHOW_FREE_MEM(WHERE) ShowFreeMem(WHERE); +#else +#define SHOW_FREE_MEM(WHERE) +#endif /*********************************************************************************************\ * Macro for SetOption synonyms diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index bf846ff8e..aae9679d0 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -693,9 +693,7 @@ void WSContentBegin(int code, int ctype) { void _WSContentSend(const char* content, size_t size) { // Lowest level sendContent for all core versions Webserver->sendContent(content, size); -#ifdef USE_DEBUG_DRIVER - ShowFreeMem(PSTR("WSContentSend")); -#endif + SHOW_FREE_MEM(PSTR("WSContentSend")); DEBUG_CORE_LOG(PSTR("WEB: Chunk size %d"), size); } diff --git a/tasmota/xdrv_02_1_mqtt_file.ino b/tasmota/xdrv_02_1_mqtt_file.ino index 4d9da0f47..d6205b73f 100644 --- a/tasmota/xdrv_02_1_mqtt_file.ino +++ b/tasmota/xdrv_02_1_mqtt_file.ino @@ -377,6 +377,9 @@ void CmndFileDownload(void) { */ if (FMqtt.file_buffer) { if (FMqtt.file_pos < FMqtt.file_size) { +#ifdef USE_TASMESH + uint32_t chunk_size = 2048; +#else uint32_t chunk_size = 4096; if (!FMqtt.file_binary) { /* @@ -386,6 +389,7 @@ void CmndFileDownload(void) { */ chunk_size = (((ResponseSize() - FileTransferHeaderSize) / 4) * 3) -2; } +#endif uint32_t bytes_left = FMqtt.file_size - FMqtt.file_pos; uint32_t write_bytes = (bytes_left < chunk_size) ? bytes_left : chunk_size; uint8_t* buffer = FMqtt.file_buffer + FMqtt.file_pos; @@ -400,6 +404,9 @@ void CmndFileDownload(void) { char* base64_data = (char*)malloc(encode_base64_length(write_bytes) +2); if (base64_data) { Response_P(PSTR("{\"Id\":%d,\"Data\":\""), FMqtt.file_id); // FileTransferHeaderSize + + SHOW_FREE_MEM(PSTR("CmndFileDownload")); + encode_base64((unsigned char*)buffer, write_bytes, (unsigned char*)base64_data); ResponseAppend_P(base64_data); ResponseAppend_P("\"}"); diff --git a/tasmota/xdrv_02_9_mqtt.ino b/tasmota/xdrv_02_9_mqtt.ino index 35bcc03f6..d9d3418e6 100644 --- a/tasmota/xdrv_02_9_mqtt.ino +++ b/tasmota/xdrv_02_9_mqtt.ino @@ -513,9 +513,7 @@ bool MqttPublishLib(const char* topic, const uint8_t* payload, unsigned int plen } void MqttDataHandler(char* mqtt_topic, uint8_t* mqtt_data, unsigned int data_len) { -#ifdef USE_DEBUG_DRIVER - ShowFreeMem(PSTR("MqttDataHandler")); -#endif + SHOW_FREE_MEM(PSTR("MqttDataHandler")); // Do not allow more data than would be feasable within stack space if (data_len >= MQTT_MAX_PACKET_SIZE) { return; } @@ -620,9 +618,7 @@ void MqttPublishLoggingAsync(bool refresh) { void MqttPublishPayload(const char* topic, const char* payload, uint32_t binary_length, bool retained) { // Publish payload string or binary when binary_length set with optional retained -#ifdef USE_DEBUG_DRIVER - ShowFreeMem(PSTR("MqttPublish")); -#endif + SHOW_FREE_MEM(PSTR("MqttPublish")); bool binary_data = (binary_length > 0); if (!binary_data) { @@ -640,7 +636,7 @@ void MqttPublishPayload(const char* topic, const char* payload, uint32_t binary_ log_data_topic = (MESHroleNode()) ? F("MSH: ") : F(D_LOG_MQTT); // MSH: or MQT: #else log_data_topic = F(D_LOG_MQTT); // MQT: -#endif +#endif // USE_TASMESH log_data_topic += topic; // stat/tasmota/STATUS2 } else { log_data_topic = F(D_LOG_RESULT); // RSL: diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index 9ebea0f39..029d02603 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -806,9 +806,7 @@ bool RulesProcessEvent(const char *json_event) Rules.busy = true; bool serviced = false; -#ifdef USE_DEBUG_DRIVER - ShowFreeMem(PSTR("RulesProcessEvent")); -#endif + SHOW_FREE_MEM(PSTR("RulesProcessEvent")); //AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: ProcessEvent |%s|"), json_event); diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index 9ed0a2390..54ee98647 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -1576,9 +1576,7 @@ void DisplayJsonValue(const char* topic, const char* device, const char* mkey, c char source[Settings->display_cols[0] - Settings->display_cols[1]]; char svalue[Settings->display_cols[1] +1]; -#ifdef USE_DEBUG_DRIVER - ShowFreeMem(PSTR("DisplayJsonValue")); -#endif + SHOW_FREE_MEM(PSTR("DisplayJsonValue")); memset(spaces, 0x20, sizeof(spaces)); spaces[sizeof(spaces) -1] = '\0';