From b112c05d9ab417a6e8254d7516f59fcf30b03e20 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 15 Aug 2021 17:26:32 +0200 Subject: [PATCH] Refactor access TasmotaGlobal.mqtt_data --- tasmota/xdrv_39_thermostat.ino | 2 +- tasmota/xdrv_59_influxdb.ino | 2 +- tasmota/xdrv_79_esp32_ble.ino | 2 +- tasmota/xdrv_interface.ino | 8 ++------ tasmota/xdsp_11_sevenseg.ino | 2 +- tasmota/xsns_75_prometheus.ino | 2 +- 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tasmota/xdrv_39_thermostat.ino b/tasmota/xdrv_39_thermostat.ino index 2078fd829..e45ef93f9 100644 --- a/tasmota/xdrv_39_thermostat.ino +++ b/tasmota/xdrv_39_thermostat.ino @@ -1328,7 +1328,7 @@ void ThermostatDebug(uint8_t ctr_output) #endif // DEBUG_THERMOSTAT void ThermostatGetLocalSensor(uint8_t ctr_output) { - String buf = TasmotaGlobal.mqtt_data; // copy the string into a new buffer that will be modified + String buf = ResponseData(); // copy the string into a new buffer that will be modified JsonParser parser((char*)buf.c_str()); JsonParserObject root = parser.getRootObject(); if (root) { diff --git a/tasmota/xdrv_59_influxdb.ino b/tasmota/xdrv_59_influxdb.ino index adbfcc7aa..9bc7f5510 100644 --- a/tasmota/xdrv_59_influxdb.ino +++ b/tasmota/xdrv_59_influxdb.ino @@ -258,7 +258,7 @@ void InfluxDbProcessJson(void) { // AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: JSON %s"), ResponseData()); - String jsonStr = TasmotaGlobal.mqtt_data; + String jsonStr = ResponseData(); JsonParser parser((char *)jsonStr.c_str()); JsonParserObject root = parser.getRootObject(); if (root) { diff --git a/tasmota/xdrv_79_esp32_ble.ino b/tasmota/xdrv_79_esp32_ble.ino index b96338f75..9f4ed2e9c 100644 --- a/tasmota/xdrv_79_esp32_ble.ino +++ b/tasmota/xdrv_79_esp32_ble.ino @@ -3123,7 +3123,7 @@ static void BLEPostMQTTSeenDevices(int type) { int remains = 0; #ifdef MQTT_DATA_STRING ResponseTime_P(PSTR("")); - String response_time = TasmotaGlobal.mqtt_data; + String response_time = ResponseData(); int maxlen = 1024; char dest[maxlen]; diff --git a/tasmota/xdrv_interface.ino b/tasmota/xdrv_interface.ino index 680e0b62f..e3c637231 100644 --- a/tasmota/xdrv_interface.ino +++ b/tasmota/xdrv_interface.ino @@ -1093,13 +1093,9 @@ bool XdrvRulesProcess(bool teleperiod, const char* event) { } bool XdrvRulesProcess(bool teleperiod) { -#ifdef MQTT_DATA_STRING - bool result = XdrvRulesProcess(teleperiod, TasmotaGlobal.mqtt_data.c_str()); - ResponseClear(); + bool result = XdrvRulesProcess(teleperiod, ResponseData()); + ResponseClear(); // Free heap space return result; -#else - return XdrvRulesProcess(teleperiod, TasmotaGlobal.mqtt_data); -#endif } #ifdef USE_DEBUG_DRIVER diff --git a/tasmota/xdsp_11_sevenseg.ino b/tasmota/xdsp_11_sevenseg.ino index d3de996e1..7f200e44a 100644 --- a/tasmota/xdsp_11_sevenseg.ino +++ b/tasmota/xdsp_11_sevenseg.ino @@ -76,7 +76,7 @@ void SevensegLog(void) int16_t valueDecimal = 0; double valueFloat = 0; uint8 fDigits = 0; - String jsonStr = TasmotaGlobal.mqtt_data; // Move from stack to heap to fix watchdogs (20180626) + String jsonStr = ResponseData(); // Move from stack to heap to fix watchdogs (20180626) JsonParser parser((char*)jsonStr.c_str()); JsonParserObject object_root = parser.getRootObject(); if (object_root) { diff --git a/tasmota/xsns_75_prometheus.ino b/tasmota/xsns_75_prometheus.ino index 921a529a8..1d38f7b03 100644 --- a/tasmota/xsns_75_prometheus.ino +++ b/tasmota/xsns_75_prometheus.ino @@ -283,7 +283,7 @@ void HandleMetrics(void) { ResponseClear(); MqttShowSensor(); //Pull sensor data - String jsonStr = TasmotaGlobal.mqtt_data; + String jsonStr = ResponseData(); JsonParser parser((char *)jsonStr.c_str()); JsonParserObject root = parser.getRootObject(); if (root) { // did JSON parsing succeed?