Fix template activation and/or module selection regression from 6.5.0.4 (#5598)

Fix template activation and/or module selection regression from 6.5.0.4 (#5598)
This commit is contained in:
Theo Arends 2019-04-08 13:26:17 +02:00
parent 3fc9db9079
commit ce53ee07e7
3 changed files with 12 additions and 5 deletions

View File

@ -1,5 +1,6 @@
/* 6.5.0.5 20190406
* Add compile time GUI hexadecimal only color options in my_user_config.h (#5586)
* Fix template activation and/or module selection regression from 6.5.0.4 (#5598)
*
* 6.5.0.4 20190402
* Fix Configure Timer Web GUI (#5568)

View File

@ -876,11 +876,11 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
if ((payload >= 0) && (payload <= MAXMODULE)) {
bool present = false;
if (0 == payload) {
payload = 255;
payload = USER_MODULE;
present = true;
} else {
payload--;
present = ValidModule(payload);
present = ValidTemplateModule(payload);
}
if (present) {
Settings.last_module = Settings.module;
@ -979,7 +979,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
if (strstr(dataBuf, "{") == nullptr) { // If no JSON it must be parameter
if ((payload > 0) && (payload <= MAXMODULE)) {
payload--;
if (ValidModule(payload)) {
if (ValidTemplateModule(payload)) {
ModuleDefault(payload); // Copy template module
if (USER_MODULE == Settings.module) { restart_flag = 2; }
}

View File

@ -846,7 +846,7 @@ uint8_t ModuleNr()
return (USER_MODULE == Settings.module) ? 0 : Settings.module +1;
}
bool ValidModule(uint8_t index)
bool ValidTemplateModule(uint8_t index)
{
for (uint8_t i = 0; i < sizeof(kModuleNiceList); i++) {
if (index == pgm_read_byte(kModuleNiceList + i)) {
@ -856,6 +856,12 @@ bool ValidModule(uint8_t index)
return false;
}
bool ValidModule(uint8_t index)
{
if (index == USER_MODULE) { return true; }
return ValidTemplateModule(index);
}
String AnyModuleName(uint8_t index)
{
if (USER_MODULE == index) {
@ -1023,7 +1029,7 @@ bool JsonTemplate(const char* dataBuf)
}
if (obj[D_JSON_BASE].success()) {
uint8_t base = obj[D_JSON_BASE];
if ((0 == base) || !ValidModule(base -1)) { base = 18; }
if ((0 == base) || !ValidTemplateModule(base -1)) { base = 18; }
Settings.user_template_base = base -1; // Default WEMOS
}
return true;