Refactor access TasmotaGlobal.mqtt_data

This commit is contained in:
Theo Arends 2021-08-15 17:26:32 +02:00
parent e5e8ef4736
commit b112c05d9a
6 changed files with 7 additions and 11 deletions

View File

@ -1328,7 +1328,7 @@ void ThermostatDebug(uint8_t ctr_output)
#endif // DEBUG_THERMOSTAT #endif // DEBUG_THERMOSTAT
void ThermostatGetLocalSensor(uint8_t ctr_output) { 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()); JsonParser parser((char*)buf.c_str());
JsonParserObject root = parser.getRootObject(); JsonParserObject root = parser.getRootObject();
if (root) { if (root) {

View File

@ -258,7 +258,7 @@ void InfluxDbProcessJson(void) {
// AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: JSON %s"), ResponseData()); // AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: JSON %s"), ResponseData());
String jsonStr = TasmotaGlobal.mqtt_data; String jsonStr = ResponseData();
JsonParser parser((char *)jsonStr.c_str()); JsonParser parser((char *)jsonStr.c_str());
JsonParserObject root = parser.getRootObject(); JsonParserObject root = parser.getRootObject();
if (root) { if (root) {

View File

@ -3123,7 +3123,7 @@ static void BLEPostMQTTSeenDevices(int type) {
int remains = 0; int remains = 0;
#ifdef MQTT_DATA_STRING #ifdef MQTT_DATA_STRING
ResponseTime_P(PSTR("")); ResponseTime_P(PSTR(""));
String response_time = TasmotaGlobal.mqtt_data; String response_time = ResponseData();
int maxlen = 1024; int maxlen = 1024;
char dest[maxlen]; char dest[maxlen];

View File

@ -1093,13 +1093,9 @@ bool XdrvRulesProcess(bool teleperiod, const char* event) {
} }
bool XdrvRulesProcess(bool teleperiod) { bool XdrvRulesProcess(bool teleperiod) {
#ifdef MQTT_DATA_STRING bool result = XdrvRulesProcess(teleperiod, ResponseData());
bool result = XdrvRulesProcess(teleperiod, TasmotaGlobal.mqtt_data.c_str()); ResponseClear(); // Free heap space
ResponseClear();
return result; return result;
#else
return XdrvRulesProcess(teleperiod, TasmotaGlobal.mqtt_data);
#endif
} }
#ifdef USE_DEBUG_DRIVER #ifdef USE_DEBUG_DRIVER

View File

@ -76,7 +76,7 @@ void SevensegLog(void)
int16_t valueDecimal = 0; int16_t valueDecimal = 0;
double valueFloat = 0; double valueFloat = 0;
uint8 fDigits = 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()); JsonParser parser((char*)jsonStr.c_str());
JsonParserObject object_root = parser.getRootObject(); JsonParserObject object_root = parser.getRootObject();
if (object_root) { if (object_root) {

View File

@ -283,7 +283,7 @@ void HandleMetrics(void) {
ResponseClear(); ResponseClear();
MqttShowSensor(); //Pull sensor data MqttShowSensor(); //Pull sensor data
String jsonStr = TasmotaGlobal.mqtt_data; String jsonStr = ResponseData();
JsonParser parser((char *)jsonStr.c_str()); JsonParser parser((char *)jsonStr.c_str());
JsonParserObject root = parser.getRootObject(); JsonParserObject root = parser.getRootObject();
if (root) { // did JSON parsing succeed? if (root) { // did JSON parsing succeed?