ESP8266 tested, fixed & working (mqtt submit_status caused hungs in ESP if no MQTT connection)

This commit is contained in:
2019-03-22 03:48:15 +03:00
parent 581c172e8e
commit 696254a932
2 changed files with 13 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
#! /bin/bash
export FLAGS="$FLAGS -DMODBUS_DISABLE"
export FLAGS="$FLAGS -DCOUNTER_DISABLE"
#export FLAGS="$FLAGS -DCOUNTER_DISABLE"
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_esp8266.sh
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then

View File

@@ -476,8 +476,11 @@ void ip_ready_config_loaded_connecting_to_broker() {
char *password = passwordBuf;
int syslogPort = 514;
char syslogDeviceHostname[16];
if (mqttArr && (aJson.getArraySize(mqttArr))) deviceName = aJson.getArrayItem(mqttArr, 0)->valuestring;
if (mqttArr && (aJson.getArraySize(mqttArr)))
{
deviceName = aJson.getArrayItem(mqttArr, 0)->valuestring;
debugSerial<<F("Device Name:")<<deviceName<<endl;
}
#ifdef SYSLOG_ENABLE
//debugSerial<<"debugSerial:";
delay(100);
@@ -617,7 +620,7 @@ void onInitialStateInitLAN() {
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
if (WiFi.status() == WL_CONNECTED) {
debugSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP();
debugSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
lanStatus = HAVE_IP_ADDRESS;//1;
} else
{
@@ -1151,7 +1154,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
// free(outstr);
debugSerial<<F("Applying.\n");
applyConfig();
debugSerial<<F("Done.\n");
}
@@ -1205,6 +1208,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
} else {
debugSerial<<response;
applyConfig();
debugSerial<<F("Done.\n");
}
} else {
debugSerial<<F("Config retrieving failed\n");
@@ -1231,6 +1235,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
} else {
debugSerial<<F("Config OK, Applying\n");
applyConfig();
debugSerial<<F("Done.\n");
}
}
} else {
@@ -1410,6 +1415,7 @@ void publishStat(){
char topic[64];
char intbuf[16];
uint32_t ut = millis()/1000UL;
if (!mqttClient.connected()) return;
// debugSerial<<F("\nfree RAM: ")<<fr;
setTopic(topic,sizeof(topic),T_DEV);
@@ -1608,6 +1614,7 @@ bool thermoDisabledOrDisconnected(aJsonObject *thermoExtensionArray, int thermoS
void thermoLoop(void) {
if (millis() < nextThermostatCheck)
return;
if (!items) return;
bool thermostatCheckPrinted = false;
for (aJsonObject *thermoItem = items->child; thermoItem; thermoItem = thermoItem->next) {
if (isThermostatWithMinArraySize(thermoItem, 5)) {