Add comments to MqttPublish

This commit is contained in:
Theo Arends 2021-04-21 10:38:20 +02:00
parent 07b2611e4d
commit 283a1201f1
1 changed files with 12 additions and 11 deletions

View File

@ -334,22 +334,23 @@ void MqttPublish(const char* topic, bool retained) {
ShowFreeMem(PSTR("MqttPublish")); ShowFreeMem(PSTR("MqttPublish"));
#endif #endif
if (Settings.flag4.mqtt_no_retain) { if (Settings.flag4.mqtt_no_retain) { // SetOption104 - Disable all MQTT retained messages, some brokers don't support it: AWS IoT, Losant
retained = false; // Some brokers don't support retained, they will disconnect if received retained = false; // Some brokers don't support retained, they will disconnect if received
} }
String log_data = F(D_LOG_RESULT); String log_data; // 20210420 Moved to heap to solve tight stack resulting in exception 2
if (Settings.flag.mqtt_enabled && MqttPublishLib(topic, retained)) { // SetOption3 - Enable MQTT if (Settings.flag.mqtt_enabled && MqttPublishLib(topic, retained)) { // SetOption3 - Enable MQTT
log_data = F(D_LOG_MQTT); log_data = F(D_LOG_MQTT); // MQT:
log_data += topic; log_data += topic; // stat/tasmota/STATUS2
} else { } else {
log_data += strrchr(topic,'/')+1; log_data = F(D_LOG_RESULT); // RSL:
retained = false; log_data += strrchr(topic,'/')+1; // STATUS2
retained = false; // Without MQTT enabled there is no retained message
} }
log_data += F(" = "); log_data += F(" = "); // =
log_data += TasmotaGlobal.mqtt_data; log_data += TasmotaGlobal.mqtt_data; // {"StatusFWR":{"Version":...
if (retained) { log_data += F(" (" D_RETAINED ")"); } if (retained) { log_data += F(" (" D_RETAINED ")"); } // (retained)
AddLogData(LOG_LEVEL_INFO, log_data.c_str()); AddLogData(LOG_LEVEL_INFO, log_data.c_str()); // MQT: stat/tasmota/STATUS2 = {"StatusFWR":{"Version":...
if (Settings.ledstate &0x04) { if (Settings.ledstate &0x04) {
TasmotaGlobal.blinks++; TasmotaGlobal.blinks++;