From 77db7ba0ffe2d8b8051c2f16240bdc9054d51588 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 14 Feb 2019 16:48:28 +0100 Subject: [PATCH] 6.4.1.17 Change template stability 6.4.1.17 20190214 * Change template update by removing possibility to add user module config keeping template as defined (#5222) --- sonoff/_changelog.ino | 5 ++++- sonoff/sonoff.ino | 14 ++++++++++++++ sonoff/sonoff_version.h | 2 +- sonoff/support.ino | 7 ++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 35e16eda8..0461104e5 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,4 +1,7 @@ -/* 6.4.1.16 20190211 +/* 6.4.1.17 20190214 + * Change template update by removing possibility to add user module config keeping template as defined (#5222) + * + * 6.4.1.16 20190211 * Initial support for online template change using command Template or GUI Configure Other (#5177) * Add parameter CFG_HOLDER to status 1 message (#5206) * Update GUI diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index c3c0e3095..8f9f93d62 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -954,7 +954,10 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len) else if (CMND_TEMPLATE == command_code) { // {"NAME":"Generic","GPIO":[17,254,29,254,7,254,254,254,138,254,139,254,254],"FLAG":1,"BASE":255} bool error = false; + if (!strstr(dataBuf, "{")) { // If no JSON it must be parameter +/* + // Version 6.4.1.16 - Add user module config data to template bool update = false; if ((payload > 0) && (payload <= MAXMODULE)) { ModuleDefault(payload -1); // Copy template module @@ -983,6 +986,17 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len) src++; } } +*/ + // Version 6.4.1.17 use template as defined + if ((payload > 0) && (payload <= MAXMODULE)) { + ModuleDefault(payload -1); // Copy template module + if (USER_MODULE == Settings.module) { restart_flag = 2; } + } + else if (0 == payload) { // Copy current module with user configured GPIO + if (Settings.module != USER_MODULE) { + ModuleDefault(Settings.module); + } + } } else if (data_len > 9) { // Workaround exception if empty JSON like {} - Needs checks StaticJsonBuffer<350> jb; // 331 from https://arduinojson.org/v5/assistant/ diff --git a/sonoff/sonoff_version.h b/sonoff/sonoff_version.h index 2c221bd1b..3816029fd 100644 --- a/sonoff/sonoff_version.h +++ b/sonoff/sonoff_version.h @@ -20,7 +20,7 @@ #ifndef _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_ -#define VERSION 0x06040110 +#define VERSION 0x06040111 #define D_PROGRAMNAME "Sonoff-Tasmota" #define D_AUTHOR "Theo Arends" diff --git a/sonoff/support.ino b/sonoff/support.ino index c728d28eb..80c1c53e3 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -783,12 +783,17 @@ uint8_t ValidPin(uint8_t pin, uint8_t gpio) bool ValidGPIO(uint8_t pin, uint8_t gpio) { bool result = false; - +/* + // Version 6.4.1.16 - Use user module config in template if (USER_MODULE == Settings.module) { result = (ValidPin(pin, gpio) > GPIO_NONE); // Allow any pin } else { result = (GPIO_USER == ValidPin(pin, gpio)); // Only allow GPIO_USER pins } +*/ + // Version 6.4.1.17 - Use template as defined + result = (GPIO_USER == ValidPin(pin, gpio)); // Only allow GPIO_USER pins + return result; }