mirror of https://github.com/arendst/Tasmota.git
Refactor ShowFreeMem
This commit is contained in:
parent
ef508c629f
commit
e02b58a6ed
|
@ -154,9 +154,7 @@ void ExecuteCommand(const char *cmnd, uint32_t source)
|
||||||
// cmnd: "status 0" = stopic "status" and svalue " 0"
|
// cmnd: "status 0" = stopic "status" and svalue " 0"
|
||||||
// cmnd: "var1 =1" = stopic "var1" and svalue " =1"
|
// cmnd: "var1 =1" = stopic "var1" and svalue " =1"
|
||||||
// cmnd: "var1=1" = stopic "var1" and svalue "=1"
|
// cmnd: "var1=1" = stopic "var1" and svalue "=1"
|
||||||
#ifdef USE_DEBUG_DRIVER
|
SHOW_FREE_MEM(PSTR("ExecuteCommand"));
|
||||||
ShowFreeMem(PSTR("ExecuteCommand"));
|
|
||||||
#endif
|
|
||||||
ShowSource(source);
|
ShowSource(source);
|
||||||
|
|
||||||
const char *pos = cmnd;
|
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)
|
void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len)
|
||||||
{
|
{
|
||||||
#ifdef USE_DEBUG_DRIVER
|
SHOW_FREE_MEM(PSTR("CommandHandler"));
|
||||||
ShowFreeMem(PSTR("CommandHandler"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool grpflg = false;
|
bool grpflg = false;
|
||||||
uint32_t real_index = SET_MQTT_GRP_TOPIC;
|
uint32_t real_index = SET_MQTT_GRP_TOPIC;
|
||||||
|
|
|
@ -502,6 +502,11 @@ bool first_device_group_is_local = true;
|
||||||
#define DEBUG_TRACE_LOG(...)
|
#define DEBUG_TRACE_LOG(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_DEBUG_DRIVER
|
||||||
|
#define SHOW_FREE_MEM(WHERE) ShowFreeMem(WHERE);
|
||||||
|
#else
|
||||||
|
#define SHOW_FREE_MEM(WHERE)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Macro for SetOption synonyms
|
* Macro for SetOption synonyms
|
||||||
|
|
|
@ -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
|
void _WSContentSend(const char* content, size_t size) { // Lowest level sendContent for all core versions
|
||||||
Webserver->sendContent(content, size);
|
Webserver->sendContent(content, size);
|
||||||
|
|
||||||
#ifdef USE_DEBUG_DRIVER
|
SHOW_FREE_MEM(PSTR("WSContentSend"));
|
||||||
ShowFreeMem(PSTR("WSContentSend"));
|
|
||||||
#endif
|
|
||||||
DEBUG_CORE_LOG(PSTR("WEB: Chunk size %d"), size);
|
DEBUG_CORE_LOG(PSTR("WEB: Chunk size %d"), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -377,6 +377,9 @@ void CmndFileDownload(void) {
|
||||||
*/
|
*/
|
||||||
if (FMqtt.file_buffer) {
|
if (FMqtt.file_buffer) {
|
||||||
if (FMqtt.file_pos < FMqtt.file_size) {
|
if (FMqtt.file_pos < FMqtt.file_size) {
|
||||||
|
#ifdef USE_TASMESH
|
||||||
|
uint32_t chunk_size = 2048;
|
||||||
|
#else
|
||||||
uint32_t chunk_size = 4096;
|
uint32_t chunk_size = 4096;
|
||||||
if (!FMqtt.file_binary) {
|
if (!FMqtt.file_binary) {
|
||||||
/*
|
/*
|
||||||
|
@ -386,6 +389,7 @@ void CmndFileDownload(void) {
|
||||||
*/
|
*/
|
||||||
chunk_size = (((ResponseSize() - FileTransferHeaderSize) / 4) * 3) -2;
|
chunk_size = (((ResponseSize() - FileTransferHeaderSize) / 4) * 3) -2;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
uint32_t bytes_left = FMqtt.file_size - FMqtt.file_pos;
|
uint32_t bytes_left = FMqtt.file_size - FMqtt.file_pos;
|
||||||
uint32_t write_bytes = (bytes_left < chunk_size) ? bytes_left : chunk_size;
|
uint32_t write_bytes = (bytes_left < chunk_size) ? bytes_left : chunk_size;
|
||||||
uint8_t* buffer = FMqtt.file_buffer + FMqtt.file_pos;
|
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);
|
char* base64_data = (char*)malloc(encode_base64_length(write_bytes) +2);
|
||||||
if (base64_data) {
|
if (base64_data) {
|
||||||
Response_P(PSTR("{\"Id\":%d,\"Data\":\""), FMqtt.file_id); // FileTransferHeaderSize
|
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);
|
encode_base64((unsigned char*)buffer, write_bytes, (unsigned char*)base64_data);
|
||||||
ResponseAppend_P(base64_data);
|
ResponseAppend_P(base64_data);
|
||||||
ResponseAppend_P("\"}");
|
ResponseAppend_P("\"}");
|
||||||
|
|
|
@ -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) {
|
void MqttDataHandler(char* mqtt_topic, uint8_t* mqtt_data, unsigned int data_len) {
|
||||||
#ifdef USE_DEBUG_DRIVER
|
SHOW_FREE_MEM(PSTR("MqttDataHandler"));
|
||||||
ShowFreeMem(PSTR("MqttDataHandler"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Do not allow more data than would be feasable within stack space
|
// Do not allow more data than would be feasable within stack space
|
||||||
if (data_len >= MQTT_MAX_PACKET_SIZE) { return; }
|
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) {
|
void MqttPublishPayload(const char* topic, const char* payload, uint32_t binary_length, bool retained) {
|
||||||
// Publish <topic> payload string or binary when binary_length set with optional retained
|
// Publish <topic> payload string or binary when binary_length set with optional retained
|
||||||
|
|
||||||
#ifdef USE_DEBUG_DRIVER
|
SHOW_FREE_MEM(PSTR("MqttPublish"));
|
||||||
ShowFreeMem(PSTR("MqttPublish"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool binary_data = (binary_length > 0);
|
bool binary_data = (binary_length > 0);
|
||||||
if (!binary_data) {
|
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:
|
log_data_topic = (MESHroleNode()) ? F("MSH: ") : F(D_LOG_MQTT); // MSH: or MQT:
|
||||||
#else
|
#else
|
||||||
log_data_topic = F(D_LOG_MQTT); // MQT:
|
log_data_topic = F(D_LOG_MQTT); // MQT:
|
||||||
#endif
|
#endif // USE_TASMESH
|
||||||
log_data_topic += topic; // stat/tasmota/STATUS2
|
log_data_topic += topic; // stat/tasmota/STATUS2
|
||||||
} else {
|
} else {
|
||||||
log_data_topic = F(D_LOG_RESULT); // RSL:
|
log_data_topic = F(D_LOG_RESULT); // RSL:
|
||||||
|
|
|
@ -806,9 +806,7 @@ bool RulesProcessEvent(const char *json_event)
|
||||||
Rules.busy = true;
|
Rules.busy = true;
|
||||||
bool serviced = false;
|
bool serviced = false;
|
||||||
|
|
||||||
#ifdef USE_DEBUG_DRIVER
|
SHOW_FREE_MEM(PSTR("RulesProcessEvent"));
|
||||||
ShowFreeMem(PSTR("RulesProcessEvent"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: ProcessEvent |%s|"), json_event);
|
//AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: ProcessEvent |%s|"), json_event);
|
||||||
|
|
||||||
|
|
|
@ -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 source[Settings->display_cols[0] - Settings->display_cols[1]];
|
||||||
char svalue[Settings->display_cols[1] +1];
|
char svalue[Settings->display_cols[1] +1];
|
||||||
|
|
||||||
#ifdef USE_DEBUG_DRIVER
|
SHOW_FREE_MEM(PSTR("DisplayJsonValue"));
|
||||||
ShowFreeMem(PSTR("DisplayJsonValue"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
memset(spaces, 0x20, sizeof(spaces));
|
memset(spaces, 0x20, sizeof(spaces));
|
||||||
spaces[sizeof(spaces) -1] = '\0';
|
spaces[sizeof(spaces) -1] = '\0';
|
||||||
|
|
Loading…
Reference in New Issue