mirror of
https://github.com/anklimov/lighthub
synced 2025-12-11 14:19:50 +03:00
Compil. fix with updated libs, CRIT locks leak fix
This commit is contained in:
@@ -20,4 +20,5 @@ int abstractOut::isActive()
|
||||
int abstractOut::Setup()
|
||||
{
|
||||
if (item) item->setCmd(CMD_OFF);
|
||||
return 1;
|
||||
}
|
||||
@@ -1041,6 +1041,7 @@ uint16_t readCache::analogReadCached (uint8_t _pin)
|
||||
uint8_t readCache::digitalReadCached(uint8_t _pin)
|
||||
{
|
||||
///TBD
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef MCP23017
|
||||
|
||||
@@ -575,6 +575,46 @@ return 0;
|
||||
// Recursive function with small stack consumption
|
||||
// if cmd defined - execute Ctrl for any group members recursively
|
||||
// else performs Activity check for group members and return true if any member is active
|
||||
bool digGroup (aJsonObject *itemArr, itemCmd *cmd, char* subItem)
|
||||
{ if (!itemArr || itemArr->type!=aJson_Array) return false;
|
||||
// Iterate across array of names
|
||||
aJsonObject *i = itemArr->child;
|
||||
configLocked++;
|
||||
while (i) {
|
||||
if (i->type == aJson_String)
|
||||
{ //debugSerial<< i->valuestring<<endl;
|
||||
aJsonObject *nextItem = aJson.getObjectItem(items, i->valuestring);
|
||||
if (nextItem && nextItem->type == aJson_Array) //nextItem is correct item
|
||||
{
|
||||
Item it(nextItem);
|
||||
if (cmd && it.isValid()) it.Ctrl(*cmd,subItem,false); //Execute (non recursive)
|
||||
//Retrieve itemType
|
||||
aJsonObject * itemtype = aJson.getArrayItem(nextItem,0);
|
||||
if (itemtype && itemtype->type == aJson_Int && itemtype->valueint == CH_GROUP)
|
||||
{ //is Group
|
||||
aJsonObject * itemSubArray = aJson.getArrayItem(nextItem,1);
|
||||
short res = digGroup(itemSubArray,cmd,subItem);
|
||||
if (!cmd && res)
|
||||
{
|
||||
configLocked--;
|
||||
return true; //Not execution, just activity check. If any channel is active - return true
|
||||
}
|
||||
}
|
||||
else // Normal channel
|
||||
if (!cmd && it.isValid() && it.isActive())
|
||||
{
|
||||
configLocked--;
|
||||
return true; //Not execution, just activity check. If any channel is active - return true
|
||||
}
|
||||
}
|
||||
}
|
||||
i = i->next;
|
||||
} //while
|
||||
configLocked--;
|
||||
return false;
|
||||
}
|
||||
/* LOCKS LEAK - maintenance critical fix
|
||||
|
||||
bool digGroup (aJsonObject *itemArr, itemCmd *cmd, char* subItem)
|
||||
{ if (!itemArr || itemArr->type!=aJson_Array) return false;
|
||||
// Iterate across array of names
|
||||
@@ -605,6 +645,7 @@ bool digGroup (aJsonObject *itemArr, itemCmd *cmd, char* subItem)
|
||||
configLocked--;
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
|
||||
{
|
||||
|
||||
@@ -943,23 +943,23 @@ return false;
|
||||
int itemCmd::doMapping(aJsonObject *mappingData)
|
||||
{
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
int itemCmd::doReverseMapping (aJsonObject *mappingData)
|
||||
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int itemCmd::doMappingCmd(aJsonObject *mappingData)
|
||||
{
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
int itemCmd::doReverseMappingCmd (aJsonObject *mappingData)
|
||||
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char * itemCmd::toString(char * Buffer, int bufLen, int sendFlags, bool scale100 )
|
||||
|
||||
@@ -403,7 +403,7 @@ void setupSyslog()
|
||||
char *syslogServer = getStringFromConfig(udpSyslogArr, 0);
|
||||
if (n>1) syslogPort = aJson.getArrayItem(udpSyslogArr, 1)->valueint;
|
||||
|
||||
inet_ntoa_r(Ethernet.localIP(),syslogDeviceHostname,sizeof(syslogDeviceHostname));
|
||||
_inet_ntoa_r(Ethernet.localIP(),syslogDeviceHostname,sizeof(syslogDeviceHostname));
|
||||
infoSerial<<F("Syslog params:")<<syslogServer<<":"<<syslogPort<<":"<<syslogDeviceHostname<<endl;
|
||||
udpSyslog.server(syslogServer, syslogPort);
|
||||
udpSyslog.deviceHostname(syslogDeviceHostname);
|
||||
@@ -820,7 +820,9 @@ void onInitialStateInitLAN() {
|
||||
WiFi.mode(WIFI_STA); // ESP 32 - WiFi.disconnect(); instead
|
||||
infoSerial<<F("WIFI AP/Password:")<<QUOTE(ESP_WIFI_AP)<<F("/")<<QUOTE(ESP_WIFI_PWD)<<endl;
|
||||
|
||||
#ifndef ARDUINO_ARCH_ESP32
|
||||
wifi_set_macaddr(STATION_IF,mac); //ESP32 to check
|
||||
#endif
|
||||
|
||||
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
||||
|
||||
@@ -1256,24 +1258,24 @@ void cmdFunctionIp(int arg_cnt, char **args)
|
||||
/*
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(NRF5)
|
||||
DNSClient dns;
|
||||
#define inet_aton(cp, addr) dns.inet_aton(cp, addr)
|
||||
#define _inet_aton(cp, addr) dns._inet_aton(cp, addr)
|
||||
#else
|
||||
#define inet_aton(cp, addr) inet_aton(cp, addr)
|
||||
#define _inet_aton(cp, addr) _inet_aton(cp, addr)
|
||||
#endif
|
||||
*/
|
||||
|
||||
// switch (arg_cnt) {
|
||||
// case 5:
|
||||
if (arg_cnt>4 && inet_aton(args[4], ip)) saveFlash(OFFSET_MASK, ip);
|
||||
if (arg_cnt>4 && _inet_aton(args[4], ip)) saveFlash(OFFSET_MASK, ip);
|
||||
else saveFlash(OFFSET_MASK, ip0);
|
||||
// case 4:
|
||||
if (arg_cnt>3 && inet_aton(args[3], ip)) saveFlash(OFFSET_GW, ip);
|
||||
if (arg_cnt>3 && _inet_aton(args[3], ip)) saveFlash(OFFSET_GW, ip);
|
||||
else saveFlash(OFFSET_GW, ip0);
|
||||
// case 3:
|
||||
if (arg_cnt>2 && inet_aton(args[2], ip)) saveFlash(OFFSET_DNS, ip);
|
||||
if (arg_cnt>2 && _inet_aton(args[2], ip)) saveFlash(OFFSET_DNS, ip);
|
||||
else saveFlash(OFFSET_DNS, ip0);
|
||||
// case 2:
|
||||
if (arg_cnt>1 && inet_aton(args[1], ip)) saveFlash(OFFSET_IP, ip);
|
||||
if (arg_cnt>1 && _inet_aton(args[1], ip)) saveFlash(OFFSET_IP, ip);
|
||||
else saveFlash(OFFSET_IP, ip0);
|
||||
// break;
|
||||
|
||||
@@ -1507,10 +1509,23 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) //|| defined (NRF5)
|
||||
HTTPClient httpClient;
|
||||
|
||||
#if defined(WIFI_ENABLE)
|
||||
WiFiClient configEthClient;
|
||||
#else
|
||||
EthernetClient configEthClient;
|
||||
#endif
|
||||
|
||||
String fullURI = "http://";
|
||||
fullURI+=configServer;
|
||||
fullURI+=URI;
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
httpClient.begin(configEthClient,fullURI);
|
||||
#else
|
||||
httpClient.begin(fullURI);
|
||||
#endif
|
||||
|
||||
int httpResponseCode = httpClient.GET();
|
||||
if (httpResponseCode > 0) {
|
||||
infoSerial.printf("[HTTP] GET... code: %d\n", httpResponseCode);
|
||||
|
||||
@@ -52,6 +52,7 @@ int out_dmx::getChanType()
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int out_dmx::PixelCtrl(itemCmd cmd, char* subItem, bool show)
|
||||
|
||||
@@ -323,7 +323,7 @@ void ReadUniqueID( uint32_t * pdwUniqueID )
|
||||
}
|
||||
|
||||
|
||||
int inet_aton(const char* aIPAddrString, IPAddress& aResult)
|
||||
int _inet_aton(const char* aIPAddrString, IPAddress& aResult)
|
||||
{
|
||||
// See if we've been given a valid IP address
|
||||
const char* p =aIPAddrString;
|
||||
@@ -393,7 +393,7 @@ int inet_aton(const char* aIPAddrString, IPAddress& aResult)
|
||||
* @return either pointer to buf which now holds the ASCII
|
||||
* representation of addr or NULL if buf was too small
|
||||
*/
|
||||
char *inet_ntoa_r(IPAddress addr, char *buf, int buflen)
|
||||
char *_inet_ntoa_r(IPAddress addr, char *buf, int buflen)
|
||||
{
|
||||
short n;
|
||||
char intbuf[4];
|
||||
|
||||
@@ -54,8 +54,8 @@ void parseBytes(const char* str, char separator, byte* bytes, int maxBytes, int
|
||||
int log(const char *str, ...);
|
||||
void printFloatValueToStr(float value, char *valstr);
|
||||
void ReadUniqueID( uint32_t * pdwUniqueID );
|
||||
int inet_aton(const char* aIPAddrString, IPAddress& aResult);
|
||||
char *inet_ntoa_r(IPAddress addr, char *buf, int buflen);
|
||||
int _inet_aton(const char* aIPAddrString, IPAddress& aResult);
|
||||
char *_inet_ntoa_r(IPAddress addr, char *buf, int buflen);
|
||||
void printIPAddress(IPAddress ipAddress);
|
||||
char* setTopic(char* buf, int8_t buflen, topicType tt, const char* suffix = NULL);
|
||||
void printUlongValueToStr(char *valstr, unsigned long value);
|
||||
|
||||
Reference in New Issue
Block a user