Add option + to command Rule

Add option + to command Rule to concatenate new rule with existing rules (#3365)
This commit is contained in:
Theo Arends 2018-07-29 14:45:42 +02:00
parent 794d9dc567
commit cc5b0aaf90
2 changed files with 13 additions and 1 deletions

View File

@ -1,4 +1,5 @@
/* 6.1.1c
* Add option + to command Rule to concatenate new rule with existing rules (#3365)
* Add initial support for sensor MPU6050 (#3352)
* Add command SerialSend4 to send binary serial data (#3345)
* Add rule triggers Wifi#Connected and Wifi#Disconnected (#3359)

View File

@ -527,7 +527,18 @@ boolean RulesCommand()
break;
}
} else {
strlcpy(Settings.rules[index -1], ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, sizeof(Settings.rules[index -1]));
int offset = 0;
if ('+' == XdrvMailbox.data[0]) {
offset = strlen(Settings.rules[index -1]);
if (XdrvMailbox.data_len < (sizeof(Settings.rules[index -1]) - offset -1)) { // Check free space
XdrvMailbox.data[0] = ' '; // Remove + and make sure at least one space is inserted
} else {
offset = -1; // Not enough space so skip it
}
}
if (offset != -1) {
strlcpy(Settings.rules[index -1] + offset, ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, sizeof(Settings.rules[index -1]));
}
}
rules_triggers[index -1] = 0; // Reset once flag
}