mirror of
https://github.com/anklimov/lighthub
synced 2025-12-11 22:29:51 +03:00
ESP8266 tested, fixed & working (mqtt submit_status caused hungs in ESP if no MQTT connection)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
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)
|
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
|
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_esp8266.sh
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||||
|
|||||||
@@ -476,8 +476,11 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
char *password = passwordBuf;
|
char *password = passwordBuf;
|
||||||
int syslogPort = 514;
|
int syslogPort = 514;
|
||||||
char syslogDeviceHostname[16];
|
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
|
#ifdef SYSLOG_ENABLE
|
||||||
//debugSerial<<"debugSerial:";
|
//debugSerial<<"debugSerial:";
|
||||||
delay(100);
|
delay(100);
|
||||||
@@ -585,7 +588,7 @@ void onInitialStateInitLAN() {
|
|||||||
debugSerial<<F("WIFI AP/Password:")<<QUOTE(ESP_WIFI_AP)<<F("/")<<QUOTE(ESP_WIFI_PWD)<<endl;
|
debugSerial<<F("WIFI AP/Password:")<<QUOTE(ESP_WIFI_AP)<<F("/")<<QUOTE(ESP_WIFI_PWD)<<endl;
|
||||||
|
|
||||||
wifi_set_macaddr(STATION_IF,mac);
|
wifi_set_macaddr(STATION_IF,mac);
|
||||||
|
|
||||||
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
||||||
int wifi_connection_wait = 10000;
|
int wifi_connection_wait = 10000;
|
||||||
|
|
||||||
@@ -617,7 +620,7 @@ void onInitialStateInitLAN() {
|
|||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
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;
|
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@@ -1151,7 +1154,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
// free(outstr);
|
// free(outstr);
|
||||||
debugSerial<<F("Applying.\n");
|
debugSerial<<F("Applying.\n");
|
||||||
applyConfig();
|
applyConfig();
|
||||||
|
debugSerial<<F("Done.\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1205,6 +1208,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
} else {
|
} else {
|
||||||
debugSerial<<response;
|
debugSerial<<response;
|
||||||
applyConfig();
|
applyConfig();
|
||||||
|
debugSerial<<F("Done.\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debugSerial<<F("Config retrieving failed\n");
|
debugSerial<<F("Config retrieving failed\n");
|
||||||
@@ -1231,6 +1235,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
} else {
|
} else {
|
||||||
debugSerial<<F("Config OK, Applying\n");
|
debugSerial<<F("Config OK, Applying\n");
|
||||||
applyConfig();
|
applyConfig();
|
||||||
|
debugSerial<<F("Done.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1410,6 +1415,7 @@ void publishStat(){
|
|||||||
char topic[64];
|
char topic[64];
|
||||||
char intbuf[16];
|
char intbuf[16];
|
||||||
uint32_t ut = millis()/1000UL;
|
uint32_t ut = millis()/1000UL;
|
||||||
|
if (!mqttClient.connected()) return;
|
||||||
|
|
||||||
// debugSerial<<F("\nfree RAM: ")<<fr;
|
// debugSerial<<F("\nfree RAM: ")<<fr;
|
||||||
setTopic(topic,sizeof(topic),T_DEV);
|
setTopic(topic,sizeof(topic),T_DEV);
|
||||||
@@ -1608,6 +1614,7 @@ bool thermoDisabledOrDisconnected(aJsonObject *thermoExtensionArray, int thermoS
|
|||||||
void thermoLoop(void) {
|
void thermoLoop(void) {
|
||||||
if (millis() < nextThermostatCheck)
|
if (millis() < nextThermostatCheck)
|
||||||
return;
|
return;
|
||||||
|
if (!items) return;
|
||||||
bool thermostatCheckPrinted = false;
|
bool thermostatCheckPrinted = false;
|
||||||
for (aJsonObject *thermoItem = items->child; thermoItem; thermoItem = thermoItem->next) {
|
for (aJsonObject *thermoItem = items->child; thermoItem; thermoItem = thermoItem->next) {
|
||||||
if (isThermostatWithMinArraySize(thermoItem, 5)) {
|
if (isThermostatWithMinArraySize(thermoItem, 5)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user