mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 19:59:50 +03:00
locks leak (Critical), config OTA (interim)
This commit is contained in:
@@ -631,10 +631,18 @@ bool digGroup (aJsonObject *itemArr, itemCmd *cmd, char* subItem)
|
|||||||
{ //is Group
|
{ //is Group
|
||||||
aJsonObject * itemSubArray = aJson.getArrayItem(nextItem,1);
|
aJsonObject * itemSubArray = aJson.getArrayItem(nextItem,1);
|
||||||
short res = digGroup(itemSubArray,cmd,subItem);
|
short res = digGroup(itemSubArray,cmd,subItem);
|
||||||
if (!cmd && res) return true; //Not execution, just activity check. If any channel is active - return true
|
if (!cmd && res)
|
||||||
|
{
|
||||||
|
configLocked--;
|
||||||
|
return true; //Not execution, just activity check. If any channel is active - return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // Normal channel
|
else // Normal channel
|
||||||
if (!cmd && it.isValid() && it.isActive()) return true; //Not execution, just activity check. If any channel is active - return true
|
if (!cmd && it.isValid() && it.isActive())
|
||||||
|
{
|
||||||
|
configLocked--;
|
||||||
|
return true; //Not execution, just activity check. If any channel is active - return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = i->next;
|
i = i->next;
|
||||||
|
|||||||
@@ -191,7 +191,8 @@ void cleanConf()
|
|||||||
{
|
{
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
debugSerial<<F("Unlocking config ...")<<endl;
|
debugSerial<<F("Unlocking config ...")<<endl;
|
||||||
while (configLocked)
|
uint32_t stamp=millis();
|
||||||
|
while (configLocked && !isTimeOver(stamp,millis(),10000))
|
||||||
{
|
{
|
||||||
//wdt_res();
|
//wdt_res();
|
||||||
cmdPoll();
|
cmdPoll();
|
||||||
@@ -206,6 +207,12 @@ while (configLocked)
|
|||||||
inputLoop();
|
inputLoop();
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configLocked)
|
||||||
|
{
|
||||||
|
errorSerial<<F("Not unlocked in 10s - continue ...")<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
debugSerial<<F("Stopping channels ...")<<endl;
|
debugSerial<<F("Stopping channels ...")<<endl;
|
||||||
//Stoping the channels
|
//Stoping the channels
|
||||||
aJsonObject * item = items->child;
|
aJsonObject * item = items->child;
|
||||||
@@ -371,7 +378,11 @@ if (element && element->type == aJson_String) return element->valuestring;
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
|
||||||
|
#define flashStorage InternalStorage
|
||||||
|
#else
|
||||||
|
InternalStorageClass flashStorage(EEPROM_offsetJSON);
|
||||||
|
#endif
|
||||||
|
|
||||||
void setupOTA(void)
|
void setupOTA(void)
|
||||||
{
|
{
|
||||||
@@ -379,7 +390,7 @@ void setupOTA(void)
|
|||||||
//if (OTA_initialized) return;
|
//if (OTA_initialized) return;
|
||||||
// ArduinoOTA.end();
|
// ArduinoOTA.end();
|
||||||
// start the OTEthernet library with internal (flash) based storage
|
// start the OTEthernet library with internal (flash) based storage
|
||||||
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", flashStorage);
|
||||||
infoSerial<<F("OTA initialized\n");
|
infoSerial<<F("OTA initialized\n");
|
||||||
//OTA_initialized=true;
|
//OTA_initialized=true;
|
||||||
#endif
|
#endif
|
||||||
@@ -475,7 +486,7 @@ lan_status lanLoop() {
|
|||||||
|
|
||||||
case LIBS_INITIALIZED:
|
case LIBS_INITIALIZED:
|
||||||
LED.set(ledRED|ledGREEN|((configLoaded)?ledBLINK:0));
|
LED.set(ledRED|ledGREEN|((configLoaded)?ledBLINK:0));
|
||||||
if (configLocked) return LIBS_INITIALIZED;
|
if (configLocked) return LIBS_INITIALIZED;
|
||||||
|
|
||||||
if (!configOk)
|
if (!configOk)
|
||||||
lanStatus = loadConfigFromHttp(0, NULL);
|
lanStatus = loadConfigFromHttp(0, NULL);
|
||||||
@@ -728,7 +739,7 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
|
|
||||||
deviceName = getStringFromConfig(mqttArr, 0);
|
deviceName = getStringFromConfig(mqttArr, 0);
|
||||||
infoSerial<<F("Device Name:")<<deviceName<<endl;
|
infoSerial<<F("Device Name:")<<deviceName<<endl;
|
||||||
debugSerial<<F("N:")<<n<<endl;
|
//debugSerial<<F("N:")<<n<<endl;
|
||||||
|
|
||||||
char *servername = getStringFromConfig(mqttArr, 1);
|
char *servername = getStringFromConfig(mqttArr, 1);
|
||||||
if (n >= 3) port = aJson.getArrayItem(mqttArr, 2)->valueint;
|
if (n >= 3) port = aJson.getArrayItem(mqttArr, 2)->valueint;
|
||||||
@@ -1159,6 +1170,7 @@ int loadConfigFromEEPROM()
|
|||||||
infoSerial<<F("Loading Config from EEPROM")<<endl;
|
infoSerial<<F("Loading Config from EEPROM")<<endl;
|
||||||
|
|
||||||
ch = EEPROM.read(EEPROM_offsetJSON);
|
ch = EEPROM.read(EEPROM_offsetJSON);
|
||||||
|
Serial.print(ch);
|
||||||
if (ch == '{') {
|
if (ch == '{') {
|
||||||
aJsonEEPROMStream as = aJsonEEPROMStream(EEPROM_offsetJSON);
|
aJsonEEPROMStream as = aJsonEEPROMStream(EEPROM_offsetJSON);
|
||||||
cleanConf();
|
cleanConf();
|
||||||
@@ -2169,7 +2181,7 @@ void thermoLoop(void) {
|
|||||||
timerThermostatCheck = millis();// + THERMOSTAT_CHECK_PERIOD;
|
timerThermostatCheck = millis();// + THERMOSTAT_CHECK_PERIOD;
|
||||||
publishStat();
|
publishStat();
|
||||||
#ifndef DISABLE_FREERAM_PRINT
|
#ifndef DISABLE_FREERAM_PRINT
|
||||||
(thermostatCheckPrinted) ? debugSerial<<F("\nRAM=")<<freeRam()<<" " : debugSerial<<F(" ")<<freeRam()<<F(" ");
|
(thermostatCheckPrinted) ? debugSerial<<F("\nRAM=")<<freeRam()<<F(" Locks:")<<configLocked: debugSerial<<F(" ")<<freeRam()<<F(" Locks:")<<configLocked;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user