mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-21 09:46:31 +00:00
Removed unused #define MQTT_DATA_STRING
support
This commit is contained in:
parent
db92a843fc
commit
ed7909f23f
@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
- Unused `#define MQTT_DATA_STRING` support
|
||||||
|
|
||||||
## [13.4.0.3] 20240402
|
## [13.4.0.3] 20240402
|
||||||
### Added
|
### Added
|
||||||
|
@ -188,4 +188,5 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
|||||||
- HASPmota demo and robotocondensed fonts [#21014](https://github.com/arendst/Tasmota/issues/21014)
|
- HASPmota demo and robotocondensed fonts [#21014](https://github.com/arendst/Tasmota/issues/21014)
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
- Unused `#define MQTT_DATA_STRING` support
|
||||||
- Berry `print "a"` syntax no longer supported [#21048](https://github.com/arendst/Tasmota/issues/21048)
|
- Berry `print "a"` syntax no longer supported [#21048](https://github.com/arendst/Tasmota/issues/21048)
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#define XFUNC_PTR_IN_ROM // Enable for keeping tables in ROM (PROGMEM) which seem to have access issues on some flash types
|
#define XFUNC_PTR_IN_ROM // Enable for keeping tables in ROM (PROGMEM) which seem to have access issues on some flash types
|
||||||
#define MQTT_DATA_STRING // Use heap instead of fixed memory for TasmotaGlobal.mqtt_data
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Power Type
|
* Power Type
|
||||||
@ -210,12 +209,7 @@ const uint16_t TOPSZ = 151; // Max number of characters in topic
|
|||||||
#else // Not ESP8266
|
#else // Not ESP8266
|
||||||
const uint16_t LOG_BUFFER_SIZE = 6096; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
|
const uint16_t LOG_BUFFER_SIZE = 6096; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
|
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
const uint16_t MAX_LOGSZ = LOG_BUFFER_SIZE -96; // Max number of characters in log line - may be overruled which will truncate log entry
|
const uint16_t MAX_LOGSZ = LOG_BUFFER_SIZE -96; // Max number of characters in log line - may be overruled which will truncate log entry
|
||||||
#else
|
|
||||||
const uint16_t MAX_LOGSZ = 700; // Max number of characters in log line
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const uint8_t SENSOR_MAX_MISS = 5; // Max number of missed sensor reads before deciding it's offline
|
const uint8_t SENSOR_MAX_MISS = 5; // Max number of missed sensor reads before deciding it's offline
|
||||||
|
|
||||||
|
@ -408,13 +408,7 @@ struct TasmotaGlobal_t {
|
|||||||
uint8_t restore_powered_off_led_counter; // Seconds before powered-off LED (LEDLink) is restored
|
uint8_t restore_powered_off_led_counter; // Seconds before powered-off LED (LEDLink) is restored
|
||||||
uint8_t pwm_dimmer_led_bri; // Adjusted brightness LED level
|
uint8_t pwm_dimmer_led_bri; // Adjusted brightness LED level
|
||||||
#endif // USE_PWM_DIMMER
|
#endif // USE_PWM_DIMMER
|
||||||
|
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
String mqtt_data; // Buffer filled by Response functions
|
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 version[16]; // Composed version string like 255.255.255.255
|
||||||
char image_name[33]; // Code image and/or commit
|
char image_name[33]; // Code image and/or commit
|
||||||
char hostname[33]; // Composed Wifi hostname
|
char hostname[33]; // Composed Wifi hostname
|
||||||
|
@ -1269,52 +1269,31 @@ char* ResponseGetTime(uint32_t format, char* time_str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char* ResponseData(void) {
|
char* ResponseData(void) {
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
return (char*)TasmotaGlobal.mqtt_data.c_str();
|
return (char*)TasmotaGlobal.mqtt_data.c_str();
|
||||||
#else
|
|
||||||
return TasmotaGlobal.mqtt_data;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ResponseSize(void) {
|
uint32_t ResponseSize(void) {
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
return MAX_LOGSZ; // Arbitratry max length satisfying full log entry
|
return MAX_LOGSZ; // Arbitratry max length satisfying full log entry
|
||||||
#else
|
|
||||||
return sizeof(TasmotaGlobal.mqtt_data);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ResponseLength(void) {
|
uint32_t ResponseLength(void) {
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
return TasmotaGlobal.mqtt_data.length();
|
return TasmotaGlobal.mqtt_data.length();
|
||||||
#else
|
|
||||||
return strlen(TasmotaGlobal.mqtt_data);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResponseClear(void) {
|
void ResponseClear(void) {
|
||||||
// Reset string length to zero
|
// Reset string length to zero
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
TasmotaGlobal.mqtt_data = "";
|
TasmotaGlobal.mqtt_data = "";
|
||||||
// TasmotaGlobal.mqtt_data = (const char*) nullptr; // Doesn't work on ESP32 as strlen() (in MqttPublishPayload) will fail (for obvious reasons)
|
// TasmotaGlobal.mqtt_data = (const char*) nullptr; // Doesn't work on ESP32 as strlen() (in MqttPublishPayload) will fail (for obvious reasons)
|
||||||
#else
|
|
||||||
TasmotaGlobal.mqtt_data[0] = '\0';
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResponseJsonStart(void) {
|
void ResponseJsonStart(void) {
|
||||||
// Insert a JSON start bracket {
|
// Insert a JSON start bracket {
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
TasmotaGlobal.mqtt_data.setCharAt(0,'{');
|
TasmotaGlobal.mqtt_data.setCharAt(0,'{');
|
||||||
#else
|
|
||||||
TasmotaGlobal.mqtt_data[0] = '{';
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Response_P(const char* format, ...) // Content send snprintf_P char data
|
int Response_P(const char* format, ...) // Content send snprintf_P char data
|
||||||
{
|
{
|
||||||
// This uses char strings. Be aware of sending %% if % is needed
|
// This uses char strings. Be aware of sending %% if % is needed
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
va_list arg;
|
va_list arg;
|
||||||
va_start(arg, format);
|
va_start(arg, format);
|
||||||
char* mqtt_data = ext_vsnprintf_malloc_P(format, arg);
|
char* mqtt_data = ext_vsnprintf_malloc_P(format, arg);
|
||||||
@ -1326,19 +1305,11 @@ int Response_P(const char* format, ...) // Content send snprintf_P char d
|
|||||||
TasmotaGlobal.mqtt_data = "";
|
TasmotaGlobal.mqtt_data = "";
|
||||||
}
|
}
|
||||||
return TasmotaGlobal.mqtt_data.length();
|
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
|
int ResponseTime_P(const char* format, ...) // Content send snprintf_P char data
|
||||||
{
|
{
|
||||||
// This uses char strings. Be aware of sending %% if % is needed
|
// This uses char strings. Be aware of sending %% if % is needed
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
char timestr[100];
|
char timestr[100];
|
||||||
TasmotaGlobal.mqtt_data = ResponseGetTime(Settings->flag2.time_format, timestr);
|
TasmotaGlobal.mqtt_data = ResponseGetTime(Settings->flag2.time_format, timestr);
|
||||||
|
|
||||||
@ -1351,23 +1322,11 @@ int ResponseTime_P(const char* format, ...) // Content send snprintf_P char d
|
|||||||
free(mqtt_data);
|
free(mqtt_data);
|
||||||
}
|
}
|
||||||
return TasmotaGlobal.mqtt_data.length();
|
return TasmotaGlobal.mqtt_data.length();
|
||||||
#else
|
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
|
|
||||||
ResponseGetTime(Settings->flag2.time_format, TasmotaGlobal.mqtt_data);
|
|
||||||
|
|
||||||
int mlen = ResponseLength();
|
|
||||||
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
|
int ResponseAppend_P(const char* format, ...) // Content send snprintf_P char data
|
||||||
{
|
{
|
||||||
// This uses char strings. Be aware of sending %% if % is needed
|
// This uses char strings. Be aware of sending %% if % is needed
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
va_list arg;
|
va_list arg;
|
||||||
va_start(arg, format);
|
va_start(arg, format);
|
||||||
char* mqtt_data = ext_vsnprintf_malloc_P(format, arg);
|
char* mqtt_data = ext_vsnprintf_malloc_P(format, arg);
|
||||||
@ -1377,14 +1336,6 @@ int ResponseAppend_P(const char* format, ...) // Content send snprintf_P char d
|
|||||||
free(mqtt_data);
|
free(mqtt_data);
|
||||||
}
|
}
|
||||||
return TasmotaGlobal.mqtt_data.length();
|
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)
|
int ResponseAppendTimeFormat(uint32_t format)
|
||||||
@ -1425,11 +1376,7 @@ int ResponseJsonEndEnd(void)
|
|||||||
|
|
||||||
bool ResponseContains_P(const char* needle) {
|
bool ResponseContains_P(const char* needle) {
|
||||||
/*
|
/*
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
return (strstr_P(TasmotaGlobal.mqtt_data.c_str(), needle) != nullptr);
|
return (strstr_P(TasmotaGlobal.mqtt_data.c_str(), needle) != nullptr);
|
||||||
#else
|
|
||||||
return (strstr_P(TasmotaGlobal.mqtt_data, needle) != nullptr);
|
|
||||||
#endif
|
|
||||||
*/
|
*/
|
||||||
return (strstr_P(ResponseData(), needle) != nullptr);
|
return (strstr_P(ResponseData(), needle) != nullptr);
|
||||||
}
|
}
|
||||||
|
@ -306,27 +306,12 @@ void ResponseCmndIdxError(void) {
|
|||||||
void ResponseCmndAll(uint32_t text_index, uint32_t count) {
|
void ResponseCmndAll(uint32_t text_index, uint32_t count) {
|
||||||
uint32_t real_index = text_index;
|
uint32_t real_index = text_index;
|
||||||
ResponseClear();
|
ResponseClear();
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
for (uint32_t i = 0; i < count; i++) {
|
for (uint32_t i = 0; i < count; i++) {
|
||||||
if ((SET_MQTT_GRP_TOPIC == text_index) && (1 == i)) { real_index = SET_MQTT_GRP_TOPIC2 -1; }
|
if ((SET_MQTT_GRP_TOPIC == text_index) && (1 == i)) { real_index = SET_MQTT_GRP_TOPIC2 -1; }
|
||||||
if ((SET_BUTTON1 == text_index) && (16 == i)) { real_index = SET_BUTTON17 -16; }
|
if ((SET_BUTTON1 == text_index) && (16 == i)) { real_index = SET_BUTTON17 -16; }
|
||||||
ResponseAppend_P(PSTR("%c\"%s%d\":\"%s\""), (i)?',':'{', XdrvMailbox.command, i +1, EscapeJSONString(SettingsText(real_index +i)).c_str());
|
ResponseAppend_P(PSTR("%c\"%s%d\":\"%s\""), (i)?',':'{', XdrvMailbox.command, i +1, EscapeJSONString(SettingsText(real_index +i)).c_str());
|
||||||
}
|
}
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
#else
|
|
||||||
bool jsflg = false;
|
|
||||||
for (uint32_t i = 0; i < count; i++) {
|
|
||||||
if ((SET_MQTT_GRP_TOPIC == text_index) && (1 == i)) { real_index = SET_MQTT_GRP_TOPIC2 -1; }
|
|
||||||
if ((ResponseAppend_P(PSTR("%c\"%s%d\":\"%s\""), (jsflg)?',':'{', XdrvMailbox.command, i +1, EscapeJSONString(SettingsText(real_index +i)).c_str()) > (MAX_LOGSZ - TOPSZ)) || (i == count -1)) {
|
|
||||||
ResponseJsonEnd();
|
|
||||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, XdrvMailbox.command);
|
|
||||||
ResponseClear();
|
|
||||||
jsflg = false;
|
|
||||||
} else {
|
|
||||||
jsflg = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
@ -1758,7 +1743,6 @@ void CmndModule(void)
|
|||||||
void CmndModules(void)
|
void CmndModules(void)
|
||||||
{
|
{
|
||||||
uint32_t midx = USER_MODULE;
|
uint32_t midx = USER_MODULE;
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
Response_P(PSTR("{\"" D_CMND_MODULES "\":{"));
|
Response_P(PSTR("{\"" D_CMND_MODULES "\":{"));
|
||||||
for (uint32_t i = 0; i <= sizeof(kModuleNiceList); i++) {
|
for (uint32_t i = 0; i <= sizeof(kModuleNiceList); i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
@ -1769,27 +1753,6 @@ void CmndModules(void)
|
|||||||
ResponseAppend_P(PSTR("\"%d\":\"%s\""), j, AnyModuleName(midx).c_str());
|
ResponseAppend_P(PSTR("\"%d\":\"%s\""), j, AnyModuleName(midx).c_str());
|
||||||
}
|
}
|
||||||
ResponseJsonEndEnd();
|
ResponseJsonEndEnd();
|
||||||
#else
|
|
||||||
uint32_t lines = 1;
|
|
||||||
bool jsflg = false;
|
|
||||||
for (uint32_t i = 0; i <= sizeof(kModuleNiceList); i++) {
|
|
||||||
if (i > 0) { midx = pgm_read_byte(kModuleNiceList + i -1); }
|
|
||||||
if (!jsflg) {
|
|
||||||
Response_P(PSTR("{\"" D_CMND_MODULES "%d\":{"), lines);
|
|
||||||
} else {
|
|
||||||
ResponseAppend_P(PSTR(","));
|
|
||||||
}
|
|
||||||
jsflg = true;
|
|
||||||
uint32_t j = i ? midx +1 : 0;
|
|
||||||
if ((ResponseAppend_P(PSTR("\"%d\":\"%s\""), j, AnyModuleName(midx).c_str()) > (MAX_LOGSZ - TOPSZ)) || (i == sizeof(kModuleNiceList))) {
|
|
||||||
ResponseJsonEndEnd();
|
|
||||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, XdrvMailbox.command);
|
|
||||||
jsflg = false;
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ResponseClear();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmndGpio(void)
|
void CmndGpio(void)
|
||||||
@ -1850,18 +1813,8 @@ void CmndGpio(void)
|
|||||||
sensor_names = kSensorNamesFixed;
|
sensor_names = kSensorNamesFixed;
|
||||||
}
|
}
|
||||||
char stemp1[TOPSZ];
|
char stemp1[TOPSZ];
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":{\"%d\":\"%s%s\"}"), i, sensor_type, GetTextIndexed(stemp1, sizeof(stemp1), sensor_name_idx, sensor_names), sindex);
|
ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":{\"%d\":\"%s%s\"}"), i, sensor_type, GetTextIndexed(stemp1, sizeof(stemp1), sensor_name_idx, sensor_names), sindex);
|
||||||
jsflg2 = true;
|
jsflg2 = true;
|
||||||
#else
|
|
||||||
if ((ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":{\"%d\":\"%s%s\"}"), i, sensor_type, GetTextIndexed(stemp1, sizeof(stemp1), sensor_name_idx, sensor_names), sindex) > (MAX_LOGSZ - TOPSZ))) {
|
|
||||||
ResponseJsonEnd();
|
|
||||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, XdrvMailbox.command);
|
|
||||||
ResponseClear();
|
|
||||||
jsflg2 = true;
|
|
||||||
jsflg = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jsflg) {
|
if (jsflg) {
|
||||||
|
@ -490,35 +490,12 @@ void CmndTimers(void)
|
|||||||
Settings->flag3.timers_enable = !Settings->flag3.timers_enable; // CMND_TIMERS
|
Settings->flag3.timers_enable = !Settings->flag3.timers_enable; // CMND_TIMERS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
Response_P(PSTR("{\"" D_CMND_TIMERS "\":\"%s\""), GetStateText(Settings->flag3.timers_enable));
|
Response_P(PSTR("{\"" D_CMND_TIMERS "\":\"%s\""), GetStateText(Settings->flag3.timers_enable));
|
||||||
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
|
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
|
||||||
ResponseAppend_P(PSTR(","));
|
ResponseAppend_P(PSTR(","));
|
||||||
PrepShowTimer(i +1);
|
PrepShowTimer(i +1);
|
||||||
}
|
}
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
#else
|
|
||||||
ResponseCmndStateText(Settings->flag3.timers_enable); // CMND_TIMERS
|
|
||||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, XdrvMailbox.command);
|
|
||||||
|
|
||||||
uint32_t jsflg = 0;
|
|
||||||
uint32_t lines = 1;
|
|
||||||
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
|
|
||||||
if (!jsflg) {
|
|
||||||
Response_P(PSTR("{\"" D_CMND_TIMERS "%d\":{"), lines++);
|
|
||||||
} else {
|
|
||||||
ResponseAppend_P(PSTR(","));
|
|
||||||
}
|
|
||||||
jsflg++;
|
|
||||||
PrepShowTimer(i +1);
|
|
||||||
if (jsflg > 3) {
|
|
||||||
ResponseJsonEndEnd();
|
|
||||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_CMND_TIMERS));
|
|
||||||
jsflg = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ResponseClear();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_SUNRISE
|
#ifdef USE_SUNRISE
|
||||||
|
@ -12582,11 +12582,7 @@ int32_t http_req(char *host, char *header, char *request) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WEBSEND_RESPONSE
|
#ifdef USE_WEBSEND_RESPONSE
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
TasmotaGlobal.mqtt_data = http.getString();
|
TasmotaGlobal.mqtt_data = http.getString();
|
||||||
#else
|
|
||||||
strlcpy(TasmotaGlobal.mqtt_data, http.getString().c_str(), ResponseSize());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#ifdef HTTP_DEBUG
|
//#ifdef HTTP_DEBUG
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@ -12655,12 +12651,7 @@ int32_t call2pwl(const char *url) {
|
|||||||
AddLog(LOG_LEVEL_INFO, PSTR("PWL: result overflow: %d"), result.length());
|
AddLog(LOG_LEVEL_INFO, PSTR("PWL: result overflow: %d"), result.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
TasmotaGlobal.mqtt_data = result;
|
TasmotaGlobal.mqtt_data = result;
|
||||||
#else
|
|
||||||
strncpy(TasmotaGlobal.mqtt_data, result.c_str(), MESSZ);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// meter aggregates has also too many tokens
|
// meter aggregates has also too many tokens
|
||||||
char *cp = (char*)result.c_str();
|
char *cp = (char*)result.c_str();
|
||||||
|
@ -445,7 +445,6 @@ void NewHAssDiscovery(void) {
|
|||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
void TryResponseAppend_P(const char *format, ...) {
|
void TryResponseAppend_P(const char *format, ...) {
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
va_list arg;
|
va_list arg;
|
||||||
va_start(arg, format);
|
va_start(arg, format);
|
||||||
char* mqtt_data = ext_vsnprintf_malloc_P(format, arg);
|
char* mqtt_data = ext_vsnprintf_malloc_P(format, arg);
|
||||||
@ -454,29 +453,6 @@ void TryResponseAppend_P(const char *format, ...) {
|
|||||||
TasmotaGlobal.mqtt_data += mqtt_data;
|
TasmotaGlobal.mqtt_data += mqtt_data;
|
||||||
free(mqtt_data);
|
free(mqtt_data);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
char dummy[2];
|
|
||||||
int dlen = vsnprintf_P(dummy, 1, format, args);
|
|
||||||
|
|
||||||
int mlen = ResponseLength();
|
|
||||||
int slen = ResponseSize() - 1 - mlen;
|
|
||||||
if (dlen >= slen)
|
|
||||||
{
|
|
||||||
AddLog(LOG_LEVEL_ERROR, PSTR("%s (%u/%u):"), kHAssError1, dlen, slen);
|
|
||||||
va_start(args, format);
|
|
||||||
char log_data[MAX_LOGSZ];
|
|
||||||
vsnprintf_P(log_data, sizeof(log_data), format, args);
|
|
||||||
AddLogData(LOG_LEVEL_ERROR, log_data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
va_start(args, format);
|
|
||||||
vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, slen, format, args);
|
|
||||||
}
|
|
||||||
va_end(args);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAssAnnounceRelayLight(void)
|
void HAssAnnounceRelayLight(void)
|
||||||
|
@ -3123,7 +3123,6 @@ static void BLEPostMQTTSeenDevices(int type) {
|
|||||||
int remains = 0;
|
int remains = 0;
|
||||||
nextSeenDev = 0;
|
nextSeenDev = 0;
|
||||||
|
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
int maxlen = 1024;
|
int maxlen = 1024;
|
||||||
char dest[maxlen];
|
char dest[maxlen];
|
||||||
do {
|
do {
|
||||||
@ -3132,20 +3131,6 @@ static void BLEPostMQTTSeenDevices(int type) {
|
|||||||
// no retain - this is present devices, not historic
|
// no retain - this is present devices, not historic
|
||||||
MqttPublishPrefixTopicRulesProcess_P((1 == type) ? TELE : STAT, PSTR("BLE"));
|
MqttPublishPrefixTopicRulesProcess_P((1 == type) ? TELE : STAT, PSTR("BLE"));
|
||||||
} while (remains);
|
} while (remains);
|
||||||
#else
|
|
||||||
memset(TasmotaGlobal.mqtt_data, 0, sizeof(TasmotaGlobal.mqtt_data));
|
|
||||||
int timelen = ResponseTime_P(PSTR(""));
|
|
||||||
char *dest = TasmotaGlobal.mqtt_data + timelen;
|
|
||||||
int maxlen = ResponseSize() -20 -timelen;
|
|
||||||
|
|
||||||
// if (!TasmotaGlobal.ota_state_flag){
|
|
||||||
do {
|
|
||||||
remains = getSeenDevicesToJson(dest, maxlen);
|
|
||||||
// no retain - this is present devices, not historic
|
|
||||||
MqttPublishPrefixTopicRulesProcess_P((1== type) ? TELE : STAT, PSTR("BLE"));
|
|
||||||
} while (remains);
|
|
||||||
// }
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BLEPostMQTT(bool onlycompleted) {
|
static void BLEPostMQTT(bool onlycompleted) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user