mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
Compare commits
31
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
194a230d20 | ||
|
|
7a5a432016 | ||
|
|
07511fe144 | ||
|
|
9a390136f9 | ||
|
|
27a03f166a | ||
|
|
0a63aeb8f0 | ||
|
|
ac83cfa249 | ||
|
|
6ef0c08bc4 | ||
|
|
1ee965067d | ||
|
|
e46a873fce | ||
|
|
784e956c96 | ||
|
|
b6eebb330a | ||
|
|
a4fe8d42d2 | ||
|
|
fa42cadfa1 | ||
|
|
d4259f4e23 | ||
|
|
aef45c06f6 | ||
|
|
828f9e6a30 | ||
|
|
e79d778cf4 | ||
|
|
965eb2d994 | ||
|
|
657fccf49f | ||
|
|
228b41a1ac | ||
|
|
3bba294eb7 | ||
|
|
0254181b3e | ||
|
|
3b67282abb | ||
|
|
38af765935 | ||
|
|
ff180b085c | ||
|
|
ac6d85e214 | ||
|
|
5511ee9f38 | ||
|
|
427a22d23b | ||
|
|
d271898968 | ||
|
|
4051f0bd2e |
@@ -18,3 +18,7 @@ lib/readme.txt
|
||||
src/Custom.h
|
||||
/ESPEasy
|
||||
test/output_export.cpp
|
||||
.vscode
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
|
||||
Vendored
+55
-1
@@ -1,3 +1,57 @@
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180922 (since mega-20180916)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Sep 22 04:00:22 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
Revert "Revert "Added 2 new operators in Calculate() function""
|
||||
|
||||
TD-er (2):
|
||||
Revert "[Scheduler] Disable command scheduler"
|
||||
Revert "Revert "Fix elseif & Add if-elseif-else nesting levels""
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180916 (since mega-20180915)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Sep 16 04:00:11 CEST 2018
|
||||
|
||||
Gijs Noorlander (3):
|
||||
Revert "Added 2 new operators in Calculate() function"
|
||||
Revert "Fix elseif & Add if-elseif-else nesting levels"
|
||||
Added warning to release notes 20180915
|
||||
|
||||
TD-er (1):
|
||||
[HW Watchdog] Backgroundtasks instead of yield during rules handling
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180915 (since mega-20180914)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Sep 15 04:00:15 CEST 2018
|
||||
Known issue:
|
||||
Causes reboots. (see [#1748](https://github.com/letscontrolit/ESPEasy/issues/1748) )
|
||||
|
||||
|
||||
Plebs (1):
|
||||
Added 2 new operators in Calculate
|
||||
|
||||
TD-er (4):
|
||||
[Scheduler] Disable command scheduler
|
||||
[Controller settings] Validate settings on load/save
|
||||
[#1713] Make hostname-unitnumber optional & validate settings
|
||||
[#1698] Incorrect sunrise value southern hemisphere
|
||||
|
||||
svmac (4):
|
||||
Fix elseif & Add if-elseif-else nesting levels
|
||||
reenabled code about !
|
||||
some code optimization
|
||||
fix mistake
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180914 (since mega-20180910)
|
||||
-------------------------------------------------
|
||||
@@ -7,7 +61,7 @@ Release date: Fri Sep 14 04:00:17 CEST 2018
|
||||
Gijs Noorlander (1):
|
||||
Added PayPal link
|
||||
|
||||
Markus Gloede (1):
|
||||
giddyhup (1):
|
||||
Fix IR plugin passing received code
|
||||
|
||||
Plebs (7):
|
||||
|
||||
+2
-2
@@ -133,7 +133,7 @@ bool MQTTConnect(int controller_idx)
|
||||
{
|
||||
++mqtt_reconnect_count;
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(controller_idx, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(controller_idx, ControllerSettings);
|
||||
if (!ControllerSettings.checkHostReachable(true))
|
||||
return false;
|
||||
if (MQTTclient.connected()) {
|
||||
@@ -309,7 +309,7 @@ void MQTTStatus(String& status)
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
int enabledMqttController = firstEnabledMQTTController();
|
||||
if (enabledMqttController >= 0) {
|
||||
LoadControllerSettings(enabledMqttController, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(enabledMqttController, ControllerSettings);
|
||||
String pubname = ControllerSettings.Subscribe;
|
||||
pubname.replace(F("/#"), F("/status"));
|
||||
parseSystemVariables(pubname, false);
|
||||
|
||||
+31
-1
@@ -325,6 +325,8 @@
|
||||
#define RULESETS_MAX 4
|
||||
#define RULES_BUFFER_SIZE 64
|
||||
#define NAME_FORMULA_LENGTH_MAX 40
|
||||
#define RULES_IF_MAX_NESTING_LEVEL 4
|
||||
|
||||
#define UDP_PACKETSIZE_MAX 2048
|
||||
|
||||
#define PIN_MODE_UNDEFINED 0
|
||||
@@ -396,8 +398,9 @@
|
||||
#endif
|
||||
|
||||
// Forward declaration
|
||||
struct ControllerSettingsStruct;
|
||||
void scheduleNextDelayQueue(unsigned long id, unsigned long nextTime);
|
||||
String LoadControllerSettings(int ControllerIndex, byte* memAddress, int datasize);
|
||||
String LoadControllerSettings(int ControllerIndex, ControllerSettingsStruct& controller_settings);
|
||||
String get_formatted_Controller_number(int controller_index);
|
||||
bool loglevelActiveFor(byte logLevel);
|
||||
void addToLog(byte loglevel, const String& string);
|
||||
@@ -405,6 +408,9 @@ void addToLog(byte logLevel, const __FlashStringHelper* flashString);
|
||||
void statusLED(boolean traffic);
|
||||
void backgroundtasks();
|
||||
|
||||
bool getBitFromUL(uint32_t number, byte bitnr);
|
||||
void setBitToUL(uint32_t& number, byte bitnr, bool value);
|
||||
|
||||
enum SettingsType {
|
||||
BasicSettings_Type = 0,
|
||||
TaskSettings_Type,
|
||||
@@ -662,6 +668,18 @@ struct SettingsStruct
|
||||
clearAll();
|
||||
}
|
||||
|
||||
// VariousBits1 defaults to 0, keep in mind when adding bit lookups.
|
||||
bool appendUnitToHostname() { return !getBitFromUL(VariousBits1, 1); }
|
||||
void appendUnitToHostname(bool value) { setBitToUL(VariousBits1, 1, !value); }
|
||||
|
||||
void validate() {
|
||||
if (UDPPort > 65535) UDPPort = 0;
|
||||
|
||||
if (Latitude < -90.0 || Latitude > 90.0) Latitude = 0.0;
|
||||
if (Longitude < -180.0 || Longitude > 180.0) Longitude = 0.0;
|
||||
if (VariousBits1 > (1 << 30)) VariousBits1 = 0;
|
||||
}
|
||||
|
||||
void clearAll() {
|
||||
PID = 0;
|
||||
Version = 0;
|
||||
@@ -704,6 +722,9 @@ struct SettingsStruct
|
||||
SyslogFacility = DEFAULT_SYSLOG_FACILITY;
|
||||
StructSize = 0;
|
||||
MQTTUseUnitNameAsClientId = 0;
|
||||
Latitude = 0.0;
|
||||
Longitude = 0.0;
|
||||
VariousBits1 = 0;
|
||||
|
||||
for (byte i = 0; i < CONTROLLER_MAX; ++i) {
|
||||
Protocol[i] = 0;
|
||||
@@ -830,6 +851,7 @@ struct SettingsStruct
|
||||
//TODO: document config.dat somewhere here
|
||||
float Latitude;
|
||||
float Longitude;
|
||||
uint32_t VariousBits1;
|
||||
|
||||
// FIXME @TD-er: As discussed in #1292, the CRC for the settings is now disabled.
|
||||
// make sure crc is the last value in the struct
|
||||
@@ -870,6 +892,14 @@ struct ControllerSettingsStruct
|
||||
unsigned int MaxRetry;
|
||||
boolean DeleteOldest; // Action to perform when buffer full, delete oldest, or ignore newest.
|
||||
|
||||
void validate() {
|
||||
if (Port > 65535) Port = 0;
|
||||
if (MinimalTimeBetweenMessages < 1) MinimalTimeBetweenMessages = 100;
|
||||
if (MinimalTimeBetweenMessages > 3600000) MinimalTimeBetweenMessages = 100;
|
||||
if (MaxQueueDepth > 25) MaxQueueDepth = 10;
|
||||
if (MaxRetry > 10) MaxRetry = 10;
|
||||
}
|
||||
|
||||
IPAddress getIP() const {
|
||||
IPAddress host(IP[0], IP[1], IP[2], IP[3]);
|
||||
return host;
|
||||
|
||||
+12
-5
@@ -147,6 +147,7 @@ String SaveSettings(void)
|
||||
// Settings have changed, save to file.
|
||||
memcpy(Settings.md5, tmp_md5, 16);
|
||||
*/
|
||||
Settings.validate();
|
||||
err=SaveToFile((char*)FILE_CONFIG, 0, (byte*)&Settings, sizeof(Settings));
|
||||
if (err.length())
|
||||
return(err);
|
||||
@@ -182,6 +183,7 @@ String LoadSettings()
|
||||
err=LoadFromFile((char*)FILE_CONFIG, 0, (byte*)&Settings, sizeof( SettingsStruct));
|
||||
if (err.length())
|
||||
return(err);
|
||||
Settings.validate();
|
||||
|
||||
// FIXME @TD-er: As discussed in #1292, the CRC for the settings is now disabled.
|
||||
/*
|
||||
@@ -433,20 +435,25 @@ String LoadCustomTaskSettings(int TaskIndex, byte* memAddress, int datasize)
|
||||
/********************************************************************************************\
|
||||
Save Controller settings to SPIFFS
|
||||
\*********************************************************************************************/
|
||||
String SaveControllerSettings(int ControllerIndex, byte* memAddress, int datasize)
|
||||
String SaveControllerSettings(int ControllerIndex, ControllerSettingsStruct& controller_settings)
|
||||
{
|
||||
checkRAM(F("SaveControllerSettings"));
|
||||
return SaveToFile(ControllerSettings_Type, ControllerIndex, (char*)FILE_CONFIG, memAddress, datasize);
|
||||
controller_settings.validate(); // Make sure the saved controller settings have proper values.
|
||||
return SaveToFile(ControllerSettings_Type, ControllerIndex,
|
||||
(char*)FILE_CONFIG, (byte*)&controller_settings, sizeof(controller_settings));
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
Load Controller settings to SPIFFS
|
||||
\*********************************************************************************************/
|
||||
String LoadControllerSettings(int ControllerIndex, byte* memAddress, int datasize)
|
||||
{
|
||||
String LoadControllerSettings(int ControllerIndex, ControllerSettingsStruct& controller_settings) {
|
||||
checkRAM(F("LoadControllerSettings"));
|
||||
return(LoadFromFile(ControllerSettings_Type, ControllerIndex, (char*)FILE_CONFIG, memAddress, datasize));
|
||||
String result =
|
||||
LoadFromFile(ControllerSettings_Type, ControllerIndex,
|
||||
(char*)FILE_CONFIG, (byte*)&controller_settings, sizeof(controller_settings));
|
||||
controller_settings.validate(); // Make sure the loaded controller settings have proper values.
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-2
@@ -418,8 +418,10 @@ void setWifiMode(WiFiMode_t wifimode) {
|
||||
String WifiGetAPssid()
|
||||
{
|
||||
String ssid(Settings.Name);
|
||||
ssid+=F("_");
|
||||
ssid+=Settings.Unit;
|
||||
if (Settings.appendUnitToHostname()) {
|
||||
ssid+=F("_");
|
||||
ssid+=Settings.Unit;
|
||||
}
|
||||
return (ssid);
|
||||
}
|
||||
|
||||
|
||||
+166
-71
@@ -206,6 +206,19 @@ boolean hasPinState(byte plugin, byte index)
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
Bitwise operators
|
||||
\*********************************************************************************************/
|
||||
bool getBitFromUL(uint32_t number, byte bitnr) {
|
||||
return (number >> bitnr) & 1UL;
|
||||
}
|
||||
|
||||
void setBitToUL(uint32_t& number, byte bitnr, bool value) {
|
||||
uint32_t newbit = value ? 1UL : 0UL;
|
||||
number ^= (-newbit ^ number) & (1UL << bitnr);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
report pin mode & state (info table) using json
|
||||
\*********************************************************************************************/
|
||||
@@ -768,7 +781,7 @@ void ResetFactory(void)
|
||||
str2ip((char*)DEFAULT_SERVER, ControllerSettings.IP);
|
||||
ControllerSettings.HostName[0]=0;
|
||||
ControllerSettings.Port = DEFAULT_PORT;
|
||||
SaveControllerSettings(0, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
SaveControllerSettings(0, ControllerSettings);
|
||||
#endif
|
||||
checkRAM(F("ResetFactory2"));
|
||||
Serial.println(F("RESET: Succesful, rebooting. (you might need to press the reset button if you've justed flashed the firmware)"));
|
||||
@@ -1687,7 +1700,8 @@ float globalstack[STACK_SIZE];
|
||||
float *sp = globalstack - 1;
|
||||
float *sp_max = &globalstack[STACK_SIZE - 1];
|
||||
|
||||
#define is_operator(c) (c == '+' || c == '-' || c == '*' || c == '/' || c == '^')
|
||||
#define is_operator(c) (c == '+' || c == '-' || c == '*' || c == '/' || c == '^' || c == '%')
|
||||
#define is_unary_operator(c) (c == '!')
|
||||
|
||||
int push(float value)
|
||||
{
|
||||
@@ -1720,6 +1734,8 @@ float apply_operator(char op, float first, float second)
|
||||
return first * second;
|
||||
case '/':
|
||||
return first / second;
|
||||
case '%':
|
||||
return round(first) % round(second);
|
||||
case '^':
|
||||
return pow(first, second);
|
||||
default:
|
||||
@@ -1727,6 +1743,17 @@ float apply_operator(char op, float first, float second)
|
||||
}
|
||||
}
|
||||
|
||||
float apply_unary_operator(char op, float first)
|
||||
{
|
||||
switch (op)
|
||||
{
|
||||
case '!':
|
||||
return (round(first) == 0) ? 1 : 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
char *next_token(char *linep)
|
||||
{
|
||||
while (isspace(*(linep++)));
|
||||
@@ -1746,8 +1773,14 @@ int RPNCalculate(char* token)
|
||||
|
||||
if (push(apply_operator(token[0], first, second)))
|
||||
return CALCULATE_ERROR_STACK_OVERFLOW;
|
||||
}
|
||||
else // Als er nog een is, dan deze ophalen
|
||||
} else if (is_unary_operator(token[0]) && token[1] == 0)
|
||||
{
|
||||
float first = pop();
|
||||
|
||||
if (push(apply_unary_operator(token[0], first)))
|
||||
return CALCULATE_ERROR_STACK_OVERFLOW;
|
||||
|
||||
} else // Als er nog een is, dan deze ophalen
|
||||
if (push(atof(token))) // is het een waarde, dan op de stack plaatsen
|
||||
return CALCULATE_ERROR_STACK_OVERFLOW;
|
||||
|
||||
@@ -1763,10 +1796,13 @@ int op_preced(const char c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '!':
|
||||
return 4;
|
||||
case '^':
|
||||
return 3;
|
||||
case '*':
|
||||
case '/':
|
||||
case '%':
|
||||
return 2;
|
||||
case '+':
|
||||
case '-':
|
||||
@@ -1784,8 +1820,10 @@ bool op_left_assoc(const char c)
|
||||
case '/':
|
||||
case '+':
|
||||
case '-':
|
||||
case '%':
|
||||
return true; // left to right
|
||||
//case '!': return false; // right to left
|
||||
case '!':
|
||||
return false; // right to left
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1799,8 +1837,10 @@ unsigned int op_arg_count(const char c)
|
||||
case '/':
|
||||
case '+':
|
||||
case '-':
|
||||
case '%':
|
||||
return 2;
|
||||
//case '!': return 1;
|
||||
case '!':
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1841,7 +1881,7 @@ int Calculate(const char *input, float* result)
|
||||
}
|
||||
|
||||
// If the token is an operator, op1, then:
|
||||
else if (is_operator(c))
|
||||
else if (is_operator(c) || is_unary_operator(c))
|
||||
{
|
||||
*(TokenPos) = 0;
|
||||
error = RPNCalculate(token);
|
||||
@@ -2096,10 +2136,10 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
bool match = false;
|
||||
bool codeBlock = false;
|
||||
bool isCommand = false;
|
||||
bool conditional = false;
|
||||
bool condition = false;
|
||||
bool ifBranche = false;
|
||||
bool ifBrancheJustMatch = false;
|
||||
bool condition[RULES_IF_MAX_NESTING_LEVEL];
|
||||
bool ifBranche[RULES_IF_MAX_NESTING_LEVEL];
|
||||
byte ifBlock = 0;
|
||||
byte fakeIfBlock = 0;
|
||||
|
||||
byte buf[RULES_BUFFER_SIZE];
|
||||
int len = 0;
|
||||
@@ -2122,9 +2162,9 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
parseCompleteNonCommentLine(
|
||||
line, event, log,
|
||||
match, codeBlock, isCommand,
|
||||
conditional, condition,
|
||||
ifBranche, ifBrancheJustMatch);
|
||||
yield();
|
||||
condition, ifBranche,
|
||||
ifBlock, fakeIfBlock);
|
||||
backgroundtasks();
|
||||
}
|
||||
|
||||
line = "";
|
||||
@@ -2144,10 +2184,11 @@ void parseCompleteNonCommentLine(
|
||||
bool& match,
|
||||
bool& codeBlock,
|
||||
bool& isCommand,
|
||||
bool& conditional,
|
||||
bool& condition,
|
||||
bool& ifBranche,
|
||||
bool& ifBrancheJustMatch) {
|
||||
bool condition[],
|
||||
bool ifBranche[],
|
||||
byte& ifBlock,
|
||||
byte& fakeIfBlock)
|
||||
{
|
||||
isCommand = true;
|
||||
|
||||
// Strip comments
|
||||
@@ -2159,6 +2200,23 @@ void parseCompleteNonCommentLine(
|
||||
// only parse [xxx#yyy] if we have a matching ruleblock or need to eval the "on" (no codeBlock)
|
||||
// This to avoid waisting CPU time...
|
||||
line = parseTemplate(line, line.length());
|
||||
|
||||
if (match && !fakeIfBlock) {
|
||||
// substitution of %eventvalue% is made here so it can be used on if statement too
|
||||
if (event.charAt(0) == '!')
|
||||
{
|
||||
line.replace(F("%eventvalue%"), event); // substitute %eventvalue% with literal event string if starting with '!'
|
||||
}
|
||||
else
|
||||
{
|
||||
int equalsPos = event.indexOf("=");
|
||||
if (equalsPos > 0)
|
||||
{
|
||||
String tmpString = event.substring(equalsPos + 1);
|
||||
line.replace(F("%eventvalue%"), tmpString); // substitute %eventvalue% with the actual value from the event
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
line.trim();
|
||||
|
||||
@@ -2173,6 +2231,8 @@ void parseCompleteNonCommentLine(
|
||||
{
|
||||
if (line.startsWith(F("on ")))
|
||||
{
|
||||
ifBlock = 0;
|
||||
fakeIfBlock = 0;
|
||||
line = line.substring(3);
|
||||
int split = line.indexOf(F(" do"));
|
||||
if (split != -1)
|
||||
@@ -2209,6 +2269,8 @@ void parseCompleteNonCommentLine(
|
||||
isCommand = false;
|
||||
codeBlock = false;
|
||||
match = false;
|
||||
ifBlock = 0;
|
||||
fakeIfBlock = 0;
|
||||
}
|
||||
|
||||
if (Settings.SerialLogLevel == LOG_LEVEL_DEBUG_DEV){
|
||||
@@ -2225,8 +2287,8 @@ void parseCompleteNonCommentLine(
|
||||
processMatchedRule(
|
||||
lcAction, action, event, log,
|
||||
match, codeBlock, isCommand,
|
||||
conditional, condition,
|
||||
ifBranche, ifBrancheJustMatch);
|
||||
condition, ifBranche,
|
||||
ifBlock, fakeIfBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2235,70 +2297,101 @@ void processMatchedRule(
|
||||
bool& match,
|
||||
bool& codeBlock,
|
||||
bool& isCommand,
|
||||
bool& conditional,
|
||||
bool& condition,
|
||||
bool& ifBranche,
|
||||
bool& ifBrancheJustMatch)
|
||||
bool condition[],
|
||||
bool ifBranche[],
|
||||
byte& ifBlock,
|
||||
byte& fakeIfBlock)
|
||||
{
|
||||
int split = lcAction.indexOf(F("if ")); // check for optional "if" condition
|
||||
if (!lcAction.startsWith(F("elseif "))) {
|
||||
if (split != -1)
|
||||
{ // There is some 'if ' in the string.
|
||||
conditional = true;
|
||||
String check = lcAction.substring(split + 3);
|
||||
|
||||
log = F("[if ");
|
||||
log += check;
|
||||
log += F("]=");
|
||||
condition = ifBrancheJustMatch == false && conditionMatchExtended(check);
|
||||
if(condition == true)
|
||||
{
|
||||
ifBrancheJustMatch = true;
|
||||
}
|
||||
ifBranche = true;
|
||||
if (fakeIfBlock)
|
||||
isCommand = false;
|
||||
else if (ifBlock)
|
||||
if (condition[ifBlock-1] != ifBranche[ifBlock-1])
|
||||
isCommand = false;
|
||||
log += toString(condition);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
int split = lcAction.indexOf(F("elseif ")); // check for optional "elseif" condition
|
||||
if (split != -1)
|
||||
{
|
||||
isCommand = false;
|
||||
if (ifBlock && !fakeIfBlock)
|
||||
{
|
||||
if (ifBranche[ifBlock-1])
|
||||
{
|
||||
if (condition[ifBlock-1])
|
||||
ifBranche[ifBlock-1] = false;
|
||||
else
|
||||
{
|
||||
String check = lcAction.substring(split + 7);
|
||||
log = F("Lev.");
|
||||
log += String(ifBlock);
|
||||
log += F(": [elseif ");
|
||||
log += check;
|
||||
log += "]=";
|
||||
condition[ifBlock-1] = conditionMatchExtended(check);
|
||||
log += toString(condition[ifBlock-1]);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Starts with 'elseif '
|
||||
String check = lcAction.substring(7);
|
||||
log = F("[elseif ");
|
||||
log += check;
|
||||
log += "]=";
|
||||
condition = ifBrancheJustMatch == false && conditionMatchExtended(check);
|
||||
if(condition == true)
|
||||
{
|
||||
split = lcAction.indexOf(F("if ")); // check for optional "if" condition
|
||||
if (split != -1)
|
||||
{
|
||||
ifBrancheJustMatch = true;
|
||||
if (ifBlock < RULES_IF_MAX_NESTING_LEVEL)
|
||||
{
|
||||
if (isCommand)
|
||||
{
|
||||
ifBlock++;
|
||||
String check = lcAction.substring(split + 3);
|
||||
log = F("Lev.");
|
||||
log += String(ifBlock);
|
||||
log += F(": [if ");
|
||||
log += check;
|
||||
log += F("]=");
|
||||
condition[ifBlock-1] = conditionMatchExtended(check);
|
||||
ifBranche[ifBlock-1] = true;
|
||||
log += toString(condition[ifBlock-1]);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
else
|
||||
fakeIfBlock++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fakeIfBlock++;
|
||||
log = F("Lev.");
|
||||
log += String(ifBlock);
|
||||
log = F(": Error: IF Nesting level exceeded!");
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
isCommand = false;
|
||||
}
|
||||
ifBranche = true;
|
||||
isCommand = false;
|
||||
log += toString(condition);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
|
||||
if (lcAction == "else") // in case of an "else" block of actions, set ifBranche to false
|
||||
if ((lcAction == F("else")) && !fakeIfBlock) // in case of an "else" block of actions, set ifBranche to false
|
||||
{
|
||||
ifBranche = false;
|
||||
ifBranche[ifBlock-1] = false;
|
||||
isCommand = false;
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("else = ");
|
||||
log += toString(conditional && (condition == ifBranche));
|
||||
log = F("Lev.");
|
||||
log += String(ifBlock);
|
||||
log += F(": [else]=");
|
||||
log += toString(condition[ifBlock-1] == ifBranche[ifBlock-1]);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
}
|
||||
|
||||
if (lcAction == "endif") // conditional block ends here
|
||||
if (lcAction == F("endif")) // conditional block ends here
|
||||
{
|
||||
conditional = false;
|
||||
if (fakeIfBlock)
|
||||
fakeIfBlock--;
|
||||
else if (ifBlock)
|
||||
ifBlock--;
|
||||
isCommand = false;
|
||||
ifBranche = false;
|
||||
ifBrancheJustMatch = false;
|
||||
}
|
||||
|
||||
// process the action if it's a command and unconditional, or conditional and the condition matches the if or else block.
|
||||
if (isCommand && ((!conditional) || (conditional && (condition == ifBranche))))
|
||||
if (isCommand)
|
||||
{
|
||||
if (event.charAt(0) == '!')
|
||||
{
|
||||
@@ -2375,19 +2468,21 @@ boolean ruleMatch(String& event, String& rule)
|
||||
// Special handling of literal string events, they should start with '!'
|
||||
if (event.charAt(0) == '!')
|
||||
{
|
||||
int pos = rule.indexOf('#');
|
||||
if (pos == -1) // no # sign in rule, use 'wildcard' match on event 'source'
|
||||
{
|
||||
tmpEvent = event.substring(0,rule.length());
|
||||
tmpRule = rule;
|
||||
}
|
||||
|
||||
pos = rule.indexOf('*');
|
||||
int pos = rule.indexOf('*');
|
||||
if (pos != -1) // a * sign in rule, so use a'wildcard' match on message
|
||||
{
|
||||
tmpEvent = event.substring(0,pos-1);
|
||||
tmpRule = rule.substring(0,pos-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = rule.indexOf('#');
|
||||
if (pos == -1) // no # sign in rule, use 'wildcard' match on event 'source'
|
||||
{
|
||||
tmpEvent = event.substring(0,rule.length());
|
||||
tmpRule = rule;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmpEvent.equalsIgnoreCase(tmpRule))
|
||||
return true;
|
||||
|
||||
+6
-2
@@ -61,8 +61,8 @@ void calcSunRiseAndSet() {
|
||||
float eqt = equationOfTime(doy);
|
||||
float dec = sunDeclination(doy);
|
||||
float da = diurnalArc(dec, Settings.Latitude);
|
||||
float rise = 12 - da - eqt - Settings.Longitude / 15.0;
|
||||
float set = 12 + da - eqt - Settings.Longitude / 15.0;
|
||||
float rise = 12 - da - eqt;
|
||||
float set = 12 + da - eqt;
|
||||
tsRise.Hour = (int)rise;
|
||||
tsRise.Minute = (rise - (int)rise) * 60.0;
|
||||
tsSet.Hour = (int)set;
|
||||
@@ -70,6 +70,10 @@ void calcSunRiseAndSet() {
|
||||
tsRise.Day = tsSet.Day = tm.Day;
|
||||
tsRise.Month = tsSet.Month = tm.Month;
|
||||
tsRise.Year = tsSet.Year = tm.Year;
|
||||
// Now apply the longitude
|
||||
int secOffset_longitude = -1.0 * (Settings.Longitude / 15.0) * 3600;
|
||||
tsSet = addSeconds(tsSet, secOffset_longitude, false);
|
||||
tsRise = addSeconds(tsRise, secOffset_longitude, false);
|
||||
breakTime(toLocal(makeTime(tsRise)), sunRise);
|
||||
breakTime(toLocal(makeTime(tsSet)), sunSet);
|
||||
}
|
||||
|
||||
+5
-3
@@ -1033,6 +1033,7 @@ void handle_config() {
|
||||
MQTTclient_should_reconnect = true;
|
||||
}
|
||||
strncpy(Settings.Name, name.c_str(), sizeof(Settings.Name));
|
||||
Settings.appendUnitToHostname(isFormItemChecked(F("appendunittohostname")));
|
||||
//strncpy(SecuritySettings.Password, password.c_str(), sizeof(SecuritySettings.Password));
|
||||
copyFormPassword(F("password"), SecuritySettings.Password, sizeof(SecuritySettings.Password));
|
||||
strncpy(SecuritySettings.WifiSSID, ssid.c_str(), sizeof(SecuritySettings.WifiSSID));
|
||||
@@ -1083,6 +1084,7 @@ void handle_config() {
|
||||
SecuritySettings.Password[25] = 0;
|
||||
addFormTextBox( F("Unit Name"), F("name"), Settings.Name, 25);
|
||||
addFormNumericBox( F("Unit Number"), F("unit"), Settings.Unit, 0, UNIT_NUMBER_MAX);
|
||||
addFormCheckBox(F("Append Unit Number to hostname"), F("appendunittohostname"), Settings.appendUnitToHostname());
|
||||
addFormPasswordBox(F("Admin Password"), F("password"), SecuritySettings.Password, 25);
|
||||
|
||||
addFormSubHeader(F("Wifi Settings"));
|
||||
@@ -1262,7 +1264,7 @@ void handle_controllers() {
|
||||
CPlugin_ptr[ProtocolIndex](CPLUGIN_INIT, &TempEvent, dummyString);
|
||||
}
|
||||
}
|
||||
addHtmlError(SaveControllerSettings(controllerindex, (byte*)&ControllerSettings, sizeof(ControllerSettings)));
|
||||
addHtmlError(SaveControllerSettings(controllerindex, ControllerSettings));
|
||||
addHtmlError(SaveSettings());
|
||||
}
|
||||
|
||||
@@ -1276,7 +1278,7 @@ void handle_controllers() {
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
for (byte x = 0; x < CONTROLLER_MAX; x++)
|
||||
{
|
||||
LoadControllerSettings(x, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(x, ControllerSettings);
|
||||
html_TR_TD();
|
||||
TXBuffer += F("<a class='button link' href=\"controllers?index=");
|
||||
TXBuffer += x + 1;
|
||||
@@ -1332,7 +1334,7 @@ void handle_controllers() {
|
||||
if (Settings.Protocol[controllerindex])
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(controllerindex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(controllerindex, ControllerSettings);
|
||||
byte choice = ControllerSettings.UseDNS;
|
||||
String options[2];
|
||||
options[0] = F("Use IP address");
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ boolean CPlugin_001(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C001_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ boolean CPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
MQTTDelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ boolean CPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
if (event->idx != 0)
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
/*
|
||||
if (!ControllerSettings.checkHostReachable(true)) {
|
||||
success = false;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ boolean CPlugin_003(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C003_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ boolean CPlugin_004(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C004_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ boolean CPlugin_005(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
MQTTDelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ boolean CPlugin_005(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_PROTOCOL_SEND:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
if (!ControllerSettings.checkHostReachable(true)) {
|
||||
success = false;
|
||||
break;
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ boolean CPlugin_006(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
MQTTDelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ boolean CPlugin_006(byte function, struct EventStruct *event, String& string)
|
||||
break;
|
||||
}
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
statusLED(true);
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ boolean CPlugin_007(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C007_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ boolean CPlugin_008(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C008_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ boolean CPlugin_008(byte function, struct EventStruct *event, String& string)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ boolean CPlugin_010(byte function, struct EventStruct *event, String& string)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ boolean Create_schedule_HTTP_C011(struct EventStruct *event)
|
||||
return false;
|
||||
}
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
C011_ConfigStruct customConfig;
|
||||
LoadCustomControllerSettings(event->ControllerIndex,(byte*)&customConfig, sizeof(customConfig));
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ boolean CPlugin_012(byte function, struct EventStruct *event, String& string)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ boolean Blynk_get(const String& command, byte controllerIndex, float *data )
|
||||
}
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(controllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(controllerIndex, ControllerSettings);
|
||||
|
||||
if ((SecuritySettings.ControllerPassword[controllerIndex][0] == 0)) {
|
||||
addLog(LOG_LEVEL_ERROR, F("Blynk : No password set"));
|
||||
|
||||
@@ -324,7 +324,7 @@ ControllerDelayHandlerStruct<MQTT_queue_element> MQTTDelayHandler;
|
||||
C##NNN##_queue_element element; \
|
||||
if (!C##NNN##_DelayHandler.getNext(element)) return; \
|
||||
ControllerSettingsStruct ControllerSettings; \
|
||||
LoadControllerSettings(element.controller_idx, (byte*)&ControllerSettings, sizeof(ControllerSettings)); \
|
||||
LoadControllerSettings(element.controller_idx, ControllerSettings); \
|
||||
C##NNN##_DelayHandler.configureControllerSettings(ControllerSettings); \
|
||||
if (!WiFiConnected(100)) { \
|
||||
scheduleNextDelayQueue(TIMER_C##NNN##_DELAY_QUEUE, C##NNN##_DelayHandler.getNextScheduleTime()); \
|
||||
|
||||
@@ -368,7 +368,7 @@ boolean MQTTConnect_037(String clientid)
|
||||
return false; // Not connected, so no use in wasting time to connect to a host.
|
||||
}
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(enabledMqttController, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(enabledMqttController, ControllerSettings);
|
||||
if (ControllerSettings.UseDNS) {
|
||||
MQTTclient_037->setServer(ControllerSettings.getHost().c_str(), ControllerSettings.Port);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user