mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-29 13:46:37 +00:00
Prep mqtt_data from char to String (prt.3)
This commit is contained in:
parent
2cd88645d1
commit
749093a697
@ -1170,36 +1170,80 @@ char* ResponseGetTime(uint32_t format, char* time_str)
|
||||
}
|
||||
|
||||
uint32_t ResponseSize(void) {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
return MESSZ;
|
||||
#else
|
||||
return sizeof(TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t ResponseLength(void) {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
return TasmotaGlobal.mqtt_data.length();
|
||||
#else
|
||||
return strlen(TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ResponseClear(void) {
|
||||
// Reset string length to zero
|
||||
#ifdef MQTT_DATA_STRING
|
||||
TasmotaGlobal.mqtt_data = "";
|
||||
#else
|
||||
TasmotaGlobal.mqtt_data[0] = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
void ResponseJsonStart(void) {
|
||||
// Insert a JSON start bracket {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
TasmotaGlobal.mqtt_data.setCharAt(0,'{');
|
||||
#else
|
||||
TasmotaGlobal.mqtt_data[0] = '{';
|
||||
#endif
|
||||
}
|
||||
|
||||
int Response_P(const char* format, ...) // Content send snprintf_P char data
|
||||
{
|
||||
// This uses char strings. Be aware of sending %% if % is needed
|
||||
#ifdef MQTT_DATA_STRING
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
char* mqtt_data = ext_vsnprintf_malloc_P(format, arg);
|
||||
va_end(arg);
|
||||
if (mqtt_data != nullptr) {
|
||||
TasmotaGlobal.mqtt_data = mqtt_data;
|
||||
free(mqtt_data);
|
||||
} else {
|
||||
TasmotaGlobal.mqtt_data = "";
|
||||
}
|
||||
return TasmotaGlobal.mqtt_data.length();
|
||||
#else
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data, ResponseSize(), format, args);
|
||||
va_end(args);
|
||||
return len;
|
||||
#endif
|
||||
}
|
||||
|
||||
int ResponseTime_P(const char* format, ...) // Content send snprintf_P char data
|
||||
{
|
||||
// This uses char strings. Be aware of sending %% if % is needed
|
||||
#ifdef MQTT_DATA_STRING
|
||||
char timestr[100];
|
||||
TasmotaGlobal.mqtt_data = ResponseGetTime(Settings.flag2.time_format, timestr);
|
||||
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
char* mqtt_data = ext_vsnprintf_malloc_P(format, arg);
|
||||
va_end(arg);
|
||||
if (mqtt_data != nullptr) {
|
||||
TasmotaGlobal.mqtt_data += mqtt_data;
|
||||
free(mqtt_data);
|
||||
}
|
||||
return TasmotaGlobal.mqtt_data.length();
|
||||
#else
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
@ -1209,17 +1253,30 @@ int ResponseTime_P(const char* format, ...) // Content send snprintf_P char d
|
||||
int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, ResponseSize() - mlen, format, args);
|
||||
va_end(args);
|
||||
return len + mlen;
|
||||
#endif
|
||||
}
|
||||
|
||||
int ResponseAppend_P(const char* format, ...) // Content send snprintf_P char data
|
||||
{
|
||||
// This uses char strings. Be aware of sending %% if % is needed
|
||||
#ifdef MQTT_DATA_STRING
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
char* mqtt_data = ext_vsnprintf_malloc_P(format, arg);
|
||||
va_end(arg);
|
||||
if (mqtt_data != nullptr) {
|
||||
TasmotaGlobal.mqtt_data += mqtt_data;
|
||||
free(mqtt_data);
|
||||
}
|
||||
return TasmotaGlobal.mqtt_data.length();
|
||||
#else
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int mlen = ResponseLength();
|
||||
int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, ResponseSize() - mlen, format, args);
|
||||
va_end(args);
|
||||
return len + mlen;
|
||||
#endif
|
||||
}
|
||||
|
||||
int ResponseAppendTimeFormat(uint32_t format)
|
||||
@ -1253,7 +1310,11 @@ int ResponseJsonEndEnd(void)
|
||||
}
|
||||
|
||||
bool ResponseContains_P(const char* needle) {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
return (strstr_P(TasmotaGlobal.mqtt_data.c_str(), needle) != nullptr);
|
||||
#else
|
||||
return (strstr_P(TasmotaGlobal.mqtt_data, needle) != nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
|
@ -1137,7 +1137,7 @@ void Every250mSeconds(void)
|
||||
char *bch = strrchr(full_ota_url, '/'); // Only consider filename after last backslash prevent change of urls having "-" in it
|
||||
if (bch == nullptr) { bch = full_ota_url; } // No path found so use filename only
|
||||
char *ech = strchr(bch, '.'); // Find file type in filename (none, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz)
|
||||
if (ech == nullptr) { ech = full_ota_url + strlen(full_ota_url); } // Point to '/0' at end of mqtt_data becoming an empty string
|
||||
if (ech == nullptr) { ech = full_ota_url + strlen(full_ota_url); } // Point to '/0' at end of full_ota_url becoming an empty string
|
||||
|
||||
//AddLog(LOG_LEVEL_DEBUG, PSTR("OTA: File type [%s]"), ech);
|
||||
|
||||
@ -1146,7 +1146,7 @@ void Every250mSeconds(void)
|
||||
|
||||
char *pch = strrchr(bch, '-'); // Find last dash (-) and ignore remainder - handles tasmota-DE
|
||||
if (pch == nullptr) { pch = ech; } // No dash so ignore filetype
|
||||
*pch = '\0'; // mqtt_data = http://domus1:80/api/arduino/tasmota
|
||||
*pch = '\0'; // full_ota_url = http://domus1:80/api/arduino/tasmota
|
||||
snprintf_P(full_ota_url, sizeof(full_ota_url), PSTR("%s-" D_JSON_MINIMAL "%s"), full_ota_url, ota_url_type); // Minimal filename must be filename-minimal
|
||||
}
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
|
@ -196,13 +196,18 @@ struct {
|
||||
String backlog[MAX_BACKLOG]; // Command backlog buffer
|
||||
#endif
|
||||
|
||||
#ifdef MQTT_DATA_STRING
|
||||
String mqtt_data; // Buffer filled by Response functions
|
||||
#else
|
||||
char mqtt_data[MESSZ]; // MQTT publish buffer
|
||||
#endif
|
||||
|
||||
char version[16]; // Composed version string like 255.255.255.255
|
||||
char image_name[33]; // Code image and/or commit
|
||||
char hostname[33]; // Composed Wifi hostname
|
||||
char serial_in_buffer[INPUT_BUFFER_SIZE]; // Receive buffer
|
||||
char mqtt_client[99]; // Composed MQTT Clientname
|
||||
char mqtt_topic[TOPSZ]; // Composed MQTT topic
|
||||
char mqtt_data[MESSZ]; // MQTT publish buffer and web page ajax buffer
|
||||
char log_buffer[LOG_BUFFER_SIZE]; // Web log buffer
|
||||
} TasmotaGlobal;
|
||||
|
||||
|
@ -266,6 +266,8 @@ const uint16_t LOG_BUFFER_SIZE = 4000; // Max number of characters in lo
|
||||
#define TASM_FILE_AUTOEXEC "/autoexec.bat" // Commands executed after restart
|
||||
#define TASM_FILE_CONFIG "/config.sys" // Settings executed after restart
|
||||
|
||||
#define MQTT_DATA_STRING // Use heap instead of fixed memory for TasmotaGlobal.mqtt_data
|
||||
|
||||
#ifndef MQTT_MAX_PACKET_SIZE
|
||||
#define MQTT_MAX_PACKET_SIZE 1200 // Bytes
|
||||
//#define MQTT_MAX_PACKET_SIZE 2048 // Bytes
|
||||
|
@ -2070,7 +2070,11 @@ void HandleOtherConfiguration(void) {
|
||||
WSContentSendStyle();
|
||||
|
||||
TemplateJson();
|
||||
#ifdef MQTT_DATA_STRING
|
||||
WSContentSend_P(HTTP_FORM_OTHER, TasmotaGlobal.mqtt_data.c_str(), (USER_MODULE == Settings.module) ? PSTR(" checked disabled") : "",
|
||||
#else
|
||||
WSContentSend_P(HTTP_FORM_OTHER, TasmotaGlobal.mqtt_data, (USER_MODULE == Settings.module) ? PSTR(" checked disabled") : "",
|
||||
#endif
|
||||
(Settings.flag.mqtt_enabled) ? PSTR(" checked") : "", // SetOption3 - Enable MQTT
|
||||
SettingsText(SET_FRIENDLYNAME1), SettingsText(SET_DEVICENAME));
|
||||
|
||||
|
@ -604,8 +604,6 @@ void MqttPublishLoggingAsync(bool refresh) {
|
||||
while (GetLog(Settings.mqttlog_level, &index, &line, &len)) {
|
||||
char stopic[TOPSZ];
|
||||
GetTopic_P(stopic, STAT, TasmotaGlobal.mqtt_topic, PSTR("LOGGING"));
|
||||
// strlcpy(TasmotaGlobal.mqtt_data, line, len); // No JSON and ugly!!
|
||||
// MqttPublishLib(stopic, (const uint8_t*)TasmotaGlobal.mqtt_data, ResponseLength(), false);
|
||||
MqttPublishLib(stopic, (const uint8_t*)line, len -1, false);
|
||||
}
|
||||
}
|
||||
@ -652,7 +650,11 @@ void MqttPublishPayload(const char* topic, const char* payload) {
|
||||
|
||||
void MqttPublish(const char* topic, bool retained) {
|
||||
// Publish <topic> default TasmotaGlobal.mqtt_data string with optional retained
|
||||
#ifdef MQTT_DATA_STRING
|
||||
MqttPublishPayload(topic, TasmotaGlobal.mqtt_data.c_str(), 0, retained);
|
||||
#else
|
||||
MqttPublishPayload(topic, TasmotaGlobal.mqtt_data, 0, retained);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MqttPublish(const char* topic) {
|
||||
@ -734,7 +736,11 @@ void MqttPublishPayloadPrefixTopicRulesProcess_P(uint32_t prefix, const char* su
|
||||
|
||||
void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic, bool retained) {
|
||||
// Publish <prefix>/<device>/<RESULT or <subtopic>> default TasmotaGlobal.mqtt_data string with optional retained
|
||||
#ifdef MQTT_DATA_STRING
|
||||
MqttPublishPayloadPrefixTopic_P(prefix, subtopic, TasmotaGlobal.mqtt_data.c_str(), 0, retained);
|
||||
#else
|
||||
MqttPublishPayloadPrefixTopic_P(prefix, subtopic, TasmotaGlobal.mqtt_data, 0, retained);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic) {
|
||||
@ -1045,9 +1051,17 @@ void MqttReconnect(void) {
|
||||
}
|
||||
|
||||
String azureMqtt_userString = String(SettingsText(SET_MQTT_HOST)) + "/" + String(SettingsText(SET_MQTT_CLIENT)); + "/?api-version=2018-06-30";
|
||||
#ifdef MQTT_DATA_STRING
|
||||
if (MqttClient.connect(TasmotaGlobal.mqtt_client, azureMqtt_userString.c_str(), azureMqtt_password.c_str(), stopic, 1, lwt_retain, TasmotaGlobal.mqtt_data.c_str(), MQTT_CLEAN_SESSION)) {
|
||||
#else
|
||||
if (MqttClient.connect(TasmotaGlobal.mqtt_client, azureMqtt_userString.c_str(), azureMqtt_password.c_str(), stopic, 1, lwt_retain, TasmotaGlobal.mqtt_data, MQTT_CLEAN_SESSION)) {
|
||||
#endif
|
||||
#else
|
||||
#ifdef MQTT_DATA_STRING
|
||||
if (MqttClient.connect(TasmotaGlobal.mqtt_client, mqtt_user, mqtt_pwd, stopic, 1, lwt_retain, TasmotaGlobal.mqtt_data.c_str(), MQTT_CLEAN_SESSION)) {
|
||||
#else
|
||||
if (MqttClient.connect(TasmotaGlobal.mqtt_client, mqtt_user, mqtt_pwd, stopic, 1, lwt_retain, TasmotaGlobal.mqtt_data, MQTT_CLEAN_SESSION)) {
|
||||
#endif
|
||||
#endif // USE_MQTT_AZURE_IOT
|
||||
#ifdef USE_MQTT_TLS
|
||||
if (Mqtt.mqtt_tls) {
|
||||
|
@ -797,7 +797,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
|
||||
|
||||
/*******************************************************************************************/
|
||||
|
||||
bool RulesProcessEvent(char *json_event)
|
||||
bool RulesProcessEvent(const char *json_event)
|
||||
{
|
||||
if (Rules.busy) { return false; }
|
||||
|
||||
@ -986,7 +986,11 @@ void RulesEvery100ms(void) {
|
||||
if (ResponseLength()) {
|
||||
ResponseJsonStart(); // {"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089}
|
||||
ResponseJsonEnd();
|
||||
#ifdef MQTT_DATA_STRING
|
||||
RulesProcessEvent(TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
RulesProcessEvent(TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2401,7 +2401,11 @@ chknext:
|
||||
char rstring[SCRIPT_MAXSSIZE];
|
||||
rstring[0] = 0;
|
||||
int8_t index = fvar;
|
||||
#ifdef MQTT_DATA_STRING
|
||||
char *wd = TasmotaGlobal.mqtt_data;
|
||||
#else
|
||||
char *wd = TasmotaGlobal.mqtt_data.c_str();
|
||||
#endif
|
||||
strlcpy(rstring, wd, glob_script_mem.max_ssize);
|
||||
if (index) {
|
||||
if (strlen(wd) && index) {
|
||||
@ -2426,7 +2430,11 @@ chknext:
|
||||
// preserve mqtt_data
|
||||
char *mqd = (char*)malloc(ResponseSize()+2);
|
||||
if (mqd) {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
strlcpy(mqd, TasmotaGlobal.mqtt_data.c_str(), ResponseSize());
|
||||
#else
|
||||
strlcpy(mqd, TasmotaGlobal.mqtt_data, ResponseSize());
|
||||
#endif
|
||||
wd = mqd;
|
||||
char *lwd = wd;
|
||||
while (index) {
|
||||
@ -4982,7 +4990,11 @@ void ScripterEvery100ms(void) {
|
||||
if (ResponseLength()) {
|
||||
ResponseJsonStart();
|
||||
ResponseJsonEnd();
|
||||
#ifdef MQTT_DATA_STRING
|
||||
Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (bitRead(Settings.rule_enabled, 0)) {
|
||||
@ -7567,7 +7579,7 @@ void ScriptJsonAppend(void) {
|
||||
#endif //USE_SCRIPT_JSON_EXPORT
|
||||
|
||||
|
||||
bool RulesProcessEvent(char *json_event) {
|
||||
bool RulesProcessEvent(const char *json_event) {
|
||||
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">E", 2, json_event);
|
||||
return true;
|
||||
}
|
||||
@ -7703,9 +7715,15 @@ int32_t http_req(char *host, char *request) {
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSEND_RESPONSE
|
||||
#ifdef MQTT_DATA_STRING
|
||||
TasmotaGlobal.mqtt_data = http.getString();
|
||||
//AddLog(LOG_LEVEL_INFO, PSTR("HTTP RESULT %s"), TasmotaGlobal.mqtt_data.c_str());
|
||||
Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
strlcpy(TasmotaGlobal.mqtt_data, http.getString().c_str(), ResponseSize());
|
||||
//AddLog(LOG_LEVEL_INFO, PSTR("HTTP RESULT %s"), TasmotaGlobal.mqtt_data);
|
||||
Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
glob_script_mem.glob_error = 0;
|
||||
#endif
|
||||
|
||||
@ -8405,6 +8423,17 @@ bool Xdrv10(uint8_t function)
|
||||
break;
|
||||
case FUNC_RULES_PROCESS:
|
||||
if (bitRead(Settings.rule_enabled, 0)) {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
#ifdef USE_SCRIPT_STATUS
|
||||
if (!strncmp_P(TasmotaGlobal.mqtt_data.c_str(), PSTR("{\"Status"), 8)) {
|
||||
Run_Scripter(">U", 2, TasmotaGlobal.mqtt_data.c_str());
|
||||
} else {
|
||||
Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data.c_str());
|
||||
}
|
||||
#else
|
||||
Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data.c_str());
|
||||
#endif
|
||||
#else // MQTT_DATA_STRING
|
||||
#ifdef USE_SCRIPT_STATUS
|
||||
if (!strncmp_P(TasmotaGlobal.mqtt_data, PSTR("{\"Status"), 8)) {
|
||||
Run_Scripter(">U", 2, TasmotaGlobal.mqtt_data);
|
||||
@ -8414,14 +8443,21 @@ bool Xdrv10(uint8_t function)
|
||||
#else
|
||||
Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
#endif // MQTT_DATA_STRING
|
||||
result = glob_script_mem.event_handeled;
|
||||
}
|
||||
break;
|
||||
case FUNC_TELEPERIOD_RULES_PROCESS:
|
||||
if (bitRead(Settings.rule_enabled, 0)) {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
if (TasmotaGlobal.mqtt_data.length()) {
|
||||
Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data.c_str());
|
||||
}
|
||||
#else
|
||||
if (TasmotaGlobal.mqtt_data[0]) {
|
||||
Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
|
@ -355,8 +355,17 @@ void NewHAssDiscovery(void)
|
||||
|
||||
// NEW DISCOVERY
|
||||
|
||||
void TryResponseAppend_P(const char *format, ...)
|
||||
{
|
||||
void TryResponseAppend_P(const char *format, ...) {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
char* mqtt_data = ext_vsnprintf_malloc_P(format, arg);
|
||||
va_end(arg);
|
||||
if (mqtt_data != nullptr) {
|
||||
TasmotaGlobal.mqtt_data += mqtt_data;
|
||||
free(mqtt_data);
|
||||
}
|
||||
#else
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
char dummy[2];
|
||||
@ -378,6 +387,7 @@ void TryResponseAppend_P(const char *format, ...)
|
||||
vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, slen, format, args);
|
||||
}
|
||||
va_end(args);
|
||||
#endif
|
||||
}
|
||||
|
||||
void HAssAnnounceRelayLight(void)
|
||||
|
@ -1301,7 +1301,11 @@ void DisplayDTVarsTeleperiod(void) {
|
||||
if (jlen < DTV_JSON_SIZE) {
|
||||
char *json = (char*)malloc(jlen + 2);
|
||||
if (json) {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
strlcpy(json, TasmotaGlobal.mqtt_data.c_str(), jlen + 1);
|
||||
#else
|
||||
strlcpy(json, TasmotaGlobal.mqtt_data, jlen + 1);
|
||||
#endif
|
||||
get_dt_vars(json);
|
||||
free(json);
|
||||
}
|
||||
@ -1320,7 +1324,11 @@ void get_dt_mqtt(void) {
|
||||
ResponseJsonStart();
|
||||
ResponseJsonEnd();
|
||||
}
|
||||
#ifdef MQTT_DATA_STRING
|
||||
get_dt_vars(TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
get_dt_vars(TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
void get_dt_vars(char *json) {
|
||||
@ -1737,8 +1745,13 @@ void DisplayLocalSensor(void)
|
||||
{
|
||||
if ((Settings.display_mode &0x02) && (0 == TasmotaGlobal.tele_period)) {
|
||||
char no_topic[1] = { 0 };
|
||||
#ifdef MQTT_DATA_STRING
|
||||
// DisplayAnalyzeJson(TasmotaGlobal.mqtt_topic, TasmotaGlobal.mqtt_data.c_str()); // Add local topic
|
||||
DisplayAnalyzeJson(no_topic, TasmotaGlobal.mqtt_data.c_str()); // Discard any topic
|
||||
#else
|
||||
// DisplayAnalyzeJson(TasmotaGlobal.mqtt_topic, TasmotaGlobal.mqtt_data); // Add local topic
|
||||
DisplayAnalyzeJson(no_topic, TasmotaGlobal.mqtt_data); // Discard any topic
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1227,7 +1227,11 @@ void TuyaSerialInput(void)
|
||||
if (Settings.flag3.tuya_serial_mqtt_publish) { // SetOption66 - Enable TuyaMcuReceived messages over Mqtt
|
||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED));
|
||||
} else {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
AddLog(LOG_LEVEL_DEBUG, TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
AddLog(LOG_LEVEL_DEBUG, TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
}
|
||||
XdrvRulesProcess(0);
|
||||
|
||||
|
@ -751,7 +751,11 @@ public:
|
||||
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
||||
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||
} else {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1577,7 +1577,11 @@ void Z_AutoConfigReportingForCluster(uint16_t shortaddr, uint16_t groupaddr, uin
|
||||
ResponseAppend_P(PSTR("}}"));
|
||||
|
||||
if (buf.len() > 0) {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `%s`"), TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `%s`"), TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
ZCLMessage zcl(buf.len()); // message is 4 bytes
|
||||
zcl.shortaddr = shortaddr;
|
||||
zcl.cluster = cluster;
|
||||
|
@ -152,7 +152,11 @@ void ZigbeeInputLoop(void) {
|
||||
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
||||
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||
} else {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
}
|
||||
// now process the message
|
||||
ZigbeeProcessInput(znp_buffer);
|
||||
@ -597,7 +601,11 @@ void ZigbeeProcessInputEZSP(SBuffer &buf) {
|
||||
log_level = LOG_LEVEL_DEBUG;
|
||||
break;
|
||||
}
|
||||
#ifdef MQTT_DATA_STRING
|
||||
AddLog(log_level, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data.c_str()); // TODO move to LOG_LEVEL_DEBUG when stable
|
||||
#else
|
||||
AddLog(log_level, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); // TODO move to LOG_LEVEL_DEBUG when stable
|
||||
#endif
|
||||
}
|
||||
|
||||
// Pass message to state machine
|
||||
|
@ -97,7 +97,11 @@ extern "C" {
|
||||
const char * command = be_tostring(vm, 2);
|
||||
be_pop(vm, 2); // clear the stack before calling, because of re-entrant call to Berry in a Rule
|
||||
ExecuteCommand(command, SRC_BERRY);
|
||||
#ifdef MQTT_DATA_STRING
|
||||
be_pushstring(vm, TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
be_pushstring(vm, TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
be_return(vm); // Return
|
||||
}
|
||||
be_raise(vm, kTypeError, nullptr);
|
||||
|
@ -1093,7 +1093,11 @@ bool XdrvRulesProcess(bool teleperiod, const char* payload) {
|
||||
}
|
||||
|
||||
bool XdrvRulesProcess(bool teleperiod) {
|
||||
#ifdef MQTT_DATA_STRING
|
||||
return XdrvRulesProcess(teleperiod, TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
return XdrvRulesProcess(teleperiod, TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_DEBUG_DRIVER
|
||||
|
@ -2689,7 +2689,11 @@ void MI32ShowSomeSensors(){
|
||||
}
|
||||
ResponseAppend_P(PSTR("}"));
|
||||
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);
|
||||
#ifdef MQTT_DATA_STRING
|
||||
//AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
//AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
|
||||
#ifdef USE_HOME_ASSISTANT
|
||||
if(hass_mode==2){
|
||||
@ -2742,7 +2746,11 @@ void MI32ShowOneMISensor(){
|
||||
id);
|
||||
|
||||
MqttPublish(SensorTopic);
|
||||
#ifdef MQTT_DATA_STRING
|
||||
//AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
//AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
}
|
||||
MI32.mqttCurrentSingleSlot++;
|
||||
}
|
||||
@ -2998,7 +3006,11 @@ void MI32DiscoveryOneMISensor(){
|
||||
//vTaskDelay(100/ portTICK_PERIOD_MS);
|
||||
}
|
||||
} // end if hass discovery
|
||||
#ifdef MQTT_DATA_STRING
|
||||
//AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
//AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data);
|
||||
#endif
|
||||
#endif //USE_HOME_ASSISTANT
|
||||
|
||||
}
|
||||
@ -3076,8 +3088,11 @@ void MI32ShowTriggeredSensors(){
|
||||
} else {
|
||||
MqttPublishPrefixTopic_P(STAT, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);
|
||||
}
|
||||
#ifdef MQTT_DATA_STRING
|
||||
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: triggered %d %s"),D_CMND_MI32, sensor, TasmotaGlobal.mqtt_data.c_str());
|
||||
#else
|
||||
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: triggered %d %s"),D_CMND_MI32, sensor, TasmotaGlobal.mqtt_data);
|
||||
|
||||
#endif
|
||||
XdrvRulesProcess(0);
|
||||
|
||||
} else { // else don't and clear
|
||||
|
Loading…
x
Reference in New Issue
Block a user